Upload project.
This commit is contained in:
parent
600a4b1b40
commit
a7e61735b8
183
.gitignore
vendored
Normal file
183
.gitignore
vendored
Normal file
@ -0,0 +1,183 @@
|
|||||||
|
### Java ###
|
||||||
|
# Compiled class file
|
||||||
|
*.class
|
||||||
|
|
||||||
|
# Log file
|
||||||
|
*.log
|
||||||
|
|
||||||
|
# BlueJ files
|
||||||
|
*.ctxt
|
||||||
|
|
||||||
|
# Mobile Tools for Java (J2ME)
|
||||||
|
.mtj.tmp/
|
||||||
|
|
||||||
|
# Package Files #
|
||||||
|
*.jar
|
||||||
|
*.war
|
||||||
|
*.nar
|
||||||
|
*.ear
|
||||||
|
*.zip
|
||||||
|
*.tar.gz
|
||||||
|
*.rar
|
||||||
|
|
||||||
|
# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
|
||||||
|
hs_err_pid*
|
||||||
|
|
||||||
|
### Maven ###
|
||||||
|
target/
|
||||||
|
pom.xml.tag
|
||||||
|
pom.xml.releaseBackup
|
||||||
|
pom.xml.versionsBackup
|
||||||
|
pom.xml.next
|
||||||
|
release.properties
|
||||||
|
dependency-reduced-pom.xml
|
||||||
|
buildNumber.properties
|
||||||
|
.mvn/timing.properties
|
||||||
|
.mvn/wrapper/maven-wrapper.jar
|
||||||
|
|
||||||
|
### NetBeans ###
|
||||||
|
nbproject/private/
|
||||||
|
build/
|
||||||
|
nbbuild/
|
||||||
|
dist/
|
||||||
|
nbdist/
|
||||||
|
.nb-gradle/
|
||||||
|
|
||||||
|
### Eclipse ###
|
||||||
|
|
||||||
|
.metadata
|
||||||
|
bin/
|
||||||
|
tmp/
|
||||||
|
*.tmp
|
||||||
|
*.bak
|
||||||
|
*.swp
|
||||||
|
*~.nib
|
||||||
|
local.properties
|
||||||
|
.settings/
|
||||||
|
.loadpath
|
||||||
|
.recommenders
|
||||||
|
|
||||||
|
# External tool builders
|
||||||
|
.externalToolBuilders/
|
||||||
|
|
||||||
|
# Locally stored "Eclipse launch configurations"
|
||||||
|
*.launch
|
||||||
|
|
||||||
|
# PyDev specific (Python IDE for Eclipse)
|
||||||
|
*.pydevproject
|
||||||
|
|
||||||
|
# CDT-specific (C/C++ Development Tooling)
|
||||||
|
.cproject
|
||||||
|
|
||||||
|
# CDT- autotools
|
||||||
|
.autotools
|
||||||
|
|
||||||
|
# Java annotation processor (APT)
|
||||||
|
.factorypath
|
||||||
|
|
||||||
|
# PDT-specific (PHP Development Tools)
|
||||||
|
.buildpath
|
||||||
|
|
||||||
|
# sbteclipse plugin
|
||||||
|
.target
|
||||||
|
|
||||||
|
# Tern plugin
|
||||||
|
.tern-project
|
||||||
|
|
||||||
|
# TeXlipse plugin
|
||||||
|
.texlipse
|
||||||
|
|
||||||
|
# STS (Spring Tool Suite)
|
||||||
|
.springBeans
|
||||||
|
|
||||||
|
# Code Recommenders
|
||||||
|
.recommenders/
|
||||||
|
|
||||||
|
# Annotation Processing
|
||||||
|
.apt_generated/
|
||||||
|
|
||||||
|
# Scala IDE specific (Scala & Java development for Eclipse)
|
||||||
|
.cache-main
|
||||||
|
.scala_dependencies
|
||||||
|
.worksheet
|
||||||
|
|
||||||
|
# Eclipse Core
|
||||||
|
.project
|
||||||
|
|
||||||
|
# JDT-specific (Eclipse Java Development Tools)
|
||||||
|
.classpath
|
||||||
|
|
||||||
|
# Annotation Processing
|
||||||
|
.apt_generated
|
||||||
|
|
||||||
|
.sts4-cache/
|
||||||
|
|
||||||
|
### Intellij ###
|
||||||
|
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and WebStorm
|
||||||
|
|
||||||
|
# User-specific stuff
|
||||||
|
.idea/**/workspace.xml
|
||||||
|
.idea/**/tasks.xml
|
||||||
|
.idea/**/usage.statistics.xml
|
||||||
|
.idea/**/dictionaries
|
||||||
|
.idea/**/shelf
|
||||||
|
|
||||||
|
# Generated files
|
||||||
|
.idea/**/contentModel.xml
|
||||||
|
|
||||||
|
# Sensitive or high-churn files
|
||||||
|
.idea/**/dataSources/
|
||||||
|
.idea/**/dataSources.ids
|
||||||
|
.idea/**/dataSources.local.xml
|
||||||
|
.idea/**/sqlDataSources.xml
|
||||||
|
.idea/**/dynamic.xml
|
||||||
|
.idea/**/uiDesigner.xml
|
||||||
|
.idea/**/dbnavigator.xml
|
||||||
|
|
||||||
|
# Gradle
|
||||||
|
.idea/**/gradle.xml
|
||||||
|
.idea/**/libraries
|
||||||
|
|
||||||
|
# Gradle and Maven with auto-import
|
||||||
|
# When using Gradle or Maven with auto-import, you should exclude module files,
|
||||||
|
# since they will be recreated, and may cause churn. Uncomment if using
|
||||||
|
# auto-import.
|
||||||
|
# .idea/modules.xml
|
||||||
|
# .idea/*.iml
|
||||||
|
# .idea/modules
|
||||||
|
|
||||||
|
# CMake
|
||||||
|
cmake-build-*/
|
||||||
|
|
||||||
|
# Mongo Explorer plugin
|
||||||
|
.idea/**/mongoSettings.xml
|
||||||
|
|
||||||
|
# File-based project format
|
||||||
|
*.iws
|
||||||
|
|
||||||
|
# IntelliJ
|
||||||
|
out/
|
||||||
|
|
||||||
|
# mpeltonen/sbt-idea plugin
|
||||||
|
.idea_modules/
|
||||||
|
|
||||||
|
# JIRA plugin
|
||||||
|
atlassian-ide-plugin.xml
|
||||||
|
|
||||||
|
# Cursive Clojure plugin
|
||||||
|
.idea/replstate.xml
|
||||||
|
|
||||||
|
# Crashlytics plugin (for Android Studio and IntelliJ)
|
||||||
|
com_crashlytics_export_strings.xml
|
||||||
|
crashlytics.properties
|
||||||
|
crashlytics-build.properties
|
||||||
|
fabric.properties
|
||||||
|
|
||||||
|
# Editor-based Rest Client
|
||||||
|
.idea/httpRequests
|
||||||
|
|
||||||
|
# Android studio 3.1+ serialized cache file
|
||||||
|
.idea/caches/build_file_checksums.ser
|
||||||
|
|
||||||
|
# Sonarlint plugin
|
||||||
|
.idea/sonarlint
|
24
LICENSE
Normal file
24
LICENSE
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
This is free and unencumbered software released into the public domain.
|
||||||
|
|
||||||
|
Anyone is free to copy, modify, publish, use, compile, sell, or
|
||||||
|
distribute this software, either in source code form or as a compiled
|
||||||
|
binary, for any purpose, commercial or non-commercial, and by any
|
||||||
|
means.
|
||||||
|
|
||||||
|
In jurisdictions that recognize copyright laws, the author or authors
|
||||||
|
of this software dedicate any and all copyright interest in the
|
||||||
|
software to the public domain. We make this dedication for the benefit
|
||||||
|
of the public at large and to the detriment of our heirs and
|
||||||
|
successors. We intend this dedication to be an overt act of
|
||||||
|
relinquishment in perpetuity of all present and future rights to this
|
||||||
|
software under copyright law.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||||
|
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||||
|
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||||
|
IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
|
||||||
|
OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
|
||||||
|
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
||||||
|
OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
|
||||||
|
For more information, please refer to <http://unlicense.org>
|
73
build.xml
Normal file
73
build.xml
Normal file
@ -0,0 +1,73 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<!-- You may freely edit this file. See commented blocks below for -->
|
||||||
|
<!-- some examples of how to customize the build. -->
|
||||||
|
<!-- (If you delete it and reopen the project it will be recreated.) -->
|
||||||
|
<!-- By default, only the Clean and Build commands use this build script. -->
|
||||||
|
<!-- Commands such as Run, Debug, and Test only use this build script if -->
|
||||||
|
<!-- the Compile on Save feature is turned off for the project. -->
|
||||||
|
<!-- You can turn off the Compile on Save (or Deploy on Save) setting -->
|
||||||
|
<!-- in the project's Project Properties dialog box.-->
|
||||||
|
<project name="seabedexplorer" default="default" basedir=".">
|
||||||
|
<description>Builds, tests, and runs the project seabedexplorer.</description>
|
||||||
|
<import file="nbproject/build-impl.xml"/>
|
||||||
|
<!--
|
||||||
|
|
||||||
|
There exist several targets which are by default empty and which can be
|
||||||
|
used for execution of your tasks. These targets are usually executed
|
||||||
|
before and after some main targets. They are:
|
||||||
|
|
||||||
|
-pre-init: called before initialization of project properties
|
||||||
|
-post-init: called after initialization of project properties
|
||||||
|
-pre-compile: called before javac compilation
|
||||||
|
-post-compile: called after javac compilation
|
||||||
|
-pre-compile-single: called before javac compilation of single file
|
||||||
|
-post-compile-single: called after javac compilation of single file
|
||||||
|
-pre-compile-test: called before javac compilation of JUnit tests
|
||||||
|
-post-compile-test: called after javac compilation of JUnit tests
|
||||||
|
-pre-compile-test-single: called before javac compilation of single JUnit test
|
||||||
|
-post-compile-test-single: called after javac compilation of single JUunit test
|
||||||
|
-pre-jar: called before JAR building
|
||||||
|
-post-jar: called after JAR building
|
||||||
|
-post-clean: called after cleaning build products
|
||||||
|
|
||||||
|
(Targets beginning with '-' are not intended to be called on their own.)
|
||||||
|
|
||||||
|
Example of inserting an obfuscator after compilation could look like this:
|
||||||
|
|
||||||
|
<target name="-post-compile">
|
||||||
|
<obfuscate>
|
||||||
|
<fileset dir="${build.classes.dir}"/>
|
||||||
|
</obfuscate>
|
||||||
|
</target>
|
||||||
|
|
||||||
|
For list of available properties check the imported
|
||||||
|
nbproject/build-impl.xml file.
|
||||||
|
|
||||||
|
|
||||||
|
Another way to customize the build is by overriding existing main targets.
|
||||||
|
The targets of interest are:
|
||||||
|
|
||||||
|
-init-macrodef-javac: defines macro for javac compilation
|
||||||
|
-init-macrodef-junit: defines macro for junit execution
|
||||||
|
-init-macrodef-debug: defines macro for class debugging
|
||||||
|
-init-macrodef-java: defines macro for class execution
|
||||||
|
-do-jar: JAR building
|
||||||
|
run: execution of project
|
||||||
|
-javadoc-build: Javadoc generation
|
||||||
|
test-report: JUnit report generation
|
||||||
|
|
||||||
|
An example of overriding the target for project execution could look like this:
|
||||||
|
|
||||||
|
<target name="run" depends="seabedexplorer-impl.jar">
|
||||||
|
<exec dir="bin" executable="launcher.exe">
|
||||||
|
<arg file="${dist.jar}"/>
|
||||||
|
</exec>
|
||||||
|
</target>
|
||||||
|
|
||||||
|
Notice that the overridden target depends on the jar target and not only on
|
||||||
|
the compile target as the regular run target does. Again, for a list of available
|
||||||
|
properties which you can use, check the target you are overriding in the
|
||||||
|
nbproject/build-impl.xml file.
|
||||||
|
|
||||||
|
-->
|
||||||
|
</project>
|
11
doc/Commands.txt
Normal file
11
doc/Commands.txt
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
all
|
||||||
|
info
|
||||||
|
scan //chemical scanner
|
||||||
|
fluid //hot fluid sampler
|
||||||
|
drill //Drill
|
||||||
|
laser //laser photography
|
||||||
|
sonar //sonar
|
||||||
|
refraction //index of refraction
|
||||||
|
ph //PH
|
||||||
|
salinity //Salinity
|
||||||
|
photosensor //photosensor
|
27252
doc/Seabed Explorer Craft.mdj
Normal file
27252
doc/Seabed Explorer Craft.mdj
Normal file
File diff suppressed because it is too large
Load Diff
3
manifest.mf
Normal file
3
manifest.mf
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
Manifest-Version: 1.0
|
||||||
|
X-COMMENT: Main-Class will be added automatically by build
|
||||||
|
|
125
src/seabedexplorer/Main_State_Pattern.java
Normal file
125
src/seabedexplorer/Main_State_Pattern.java
Normal file
@ -0,0 +1,125 @@
|
|||||||
|
|
||||||
|
package seabedexplorer;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Random;
|
||||||
|
import java.util.Scanner;
|
||||||
|
import seabedexplorer.submersible.*;
|
||||||
|
import seabedexplorer.submersible.equipment.locationtracking.Location;
|
||||||
|
import seabedexplorer.submersible.state.states.*;
|
||||||
|
import seabedexplorer.util.submersible.*;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author Stedos
|
||||||
|
*/
|
||||||
|
public class Main_State_Pattern {
|
||||||
|
|
||||||
|
public static void main(String[] args) throws InterruptedException
|
||||||
|
{
|
||||||
|
/////////
|
||||||
|
//Tests//
|
||||||
|
/////////
|
||||||
|
|
||||||
|
//Create scanner for pauses in demonstration.
|
||||||
|
Scanner sc = new Scanner(System.in);
|
||||||
|
|
||||||
|
//Generate random submersible (with all equipment attached)
|
||||||
|
SubmersibleBuilder subBuilder = new SubmersibleBuilder(generateRandomSubType());
|
||||||
|
subBuilder.addAll();
|
||||||
|
Submersible sub = subBuilder.build();
|
||||||
|
//Print out all submersibles
|
||||||
|
System.out.println(sub.toString());
|
||||||
|
System.out.println();
|
||||||
|
System.out.println();
|
||||||
|
System.out.println();
|
||||||
|
|
||||||
|
//Pause until user presses enter (to temp pause)
|
||||||
|
sc.nextLine();
|
||||||
|
|
||||||
|
//Change states of submersibles to docked (should be as default, but this is a check)
|
||||||
|
System.out.println();
|
||||||
|
System.out.println(sub.getSubmersibleType() + ": ");
|
||||||
|
sub.changeState(new DockedState());
|
||||||
|
|
||||||
|
//Pause until user presses enter (to temp pause)
|
||||||
|
sc.nextLine();
|
||||||
|
|
||||||
|
//Move first submersible
|
||||||
|
System.out.println(sub.getSubmersibleType() + ": ");
|
||||||
|
sub.move(new Location(6, 4, -10));
|
||||||
|
System.out.println();
|
||||||
|
|
||||||
|
|
||||||
|
//Pause until user presses enter (to temp pause)
|
||||||
|
sc.nextLine();
|
||||||
|
|
||||||
|
//Print out sub types and states
|
||||||
|
System.out.println();
|
||||||
|
System.out.println(sub.getSubmersibleType());
|
||||||
|
System.out.println(sub.getState().toString());
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//Data collection
|
||||||
|
//Try collecting material data for each sub
|
||||||
|
System.out.println();
|
||||||
|
System.out.println(sub.collectMaterial());
|
||||||
|
System.out.println(sub.toString());
|
||||||
|
|
||||||
|
//Pause until user presses enter (to temp pause)
|
||||||
|
sc.nextLine();
|
||||||
|
|
||||||
|
//Print out states for all submersibles
|
||||||
|
System.out.println();
|
||||||
|
System.out.println("Sub is currently in state: " + sub.getState().toString());
|
||||||
|
System.out.println(sub.toString());
|
||||||
|
|
||||||
|
//Pause until user presses enter (to temp pause)
|
||||||
|
sc.nextLine();
|
||||||
|
|
||||||
|
//Collect water sample (shows water sample can't be collected on a full inventory)
|
||||||
|
System.out.println();
|
||||||
|
sub.collectWater();
|
||||||
|
System.out.println("Sub is currently in state: " + sub.getState().toString());
|
||||||
|
|
||||||
|
//Pause until user presses enter (to temp pause)
|
||||||
|
sc.nextLine();
|
||||||
|
|
||||||
|
//Collect mapping sample (shows mapping data can be collected while inventory is full)
|
||||||
|
System.out.println();
|
||||||
|
sub.collectMappingData();
|
||||||
|
System.out.println("Sub is currently in state: " + sub.getState().toString());
|
||||||
|
|
||||||
|
|
||||||
|
//Pause until user presses enter (to temp pause)
|
||||||
|
sc.nextLine();
|
||||||
|
|
||||||
|
//Return to vessel
|
||||||
|
System.out.println();
|
||||||
|
sub.returnToVessel();
|
||||||
|
|
||||||
|
//Pause until user presses enter (to temp pause)
|
||||||
|
sc.nextLine();
|
||||||
|
|
||||||
|
//Print out final states and finish
|
||||||
|
System.out.println();
|
||||||
|
System.out.println(sub.getSubmersibleType());
|
||||||
|
System.out.println(sub.getState().toString());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private static SubmersibleType generateRandomSubType()
|
||||||
|
{
|
||||||
|
Random r = new Random();
|
||||||
|
switch(r.nextInt(3))
|
||||||
|
{
|
||||||
|
case 0: return SubmersibleType.AUTOMATED_UNDERWATER_VEHICLE;
|
||||||
|
case 1: return SubmersibleType.MANNED_SUBMERSIBLE;
|
||||||
|
case 2: return SubmersibleType.REMOTE_OPERATED_VEHICLE;
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
11
src/seabedexplorer/data/Data.java
Normal file
11
src/seabedexplorer/data/Data.java
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
package seabedexplorer.data;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Data. Links all Data classes together as one data type.
|
||||||
|
*
|
||||||
|
* @author Dan Lawrence
|
||||||
|
*/
|
||||||
|
public interface Data
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
86
src/seabedexplorer/data/IndexOfRefractionReading.java
Normal file
86
src/seabedexplorer/data/IndexOfRefractionReading.java
Normal file
@ -0,0 +1,86 @@
|
|||||||
|
|
||||||
|
package seabedexplorer.data;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* IndexOfRefractionReading. Stores an angle of incidence, an angle of
|
||||||
|
* refraction, and an index of refraction. The former is inherent, the latter is
|
||||||
|
* calculated, and the other is recorded.
|
||||||
|
*
|
||||||
|
* @author Dan Lawrence
|
||||||
|
*/
|
||||||
|
public class IndexOfRefractionReading extends WaterReading {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The index of refraction.
|
||||||
|
*/
|
||||||
|
double indexOfRefraction;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The angle of incidence, in degrees.
|
||||||
|
*/
|
||||||
|
double angleOfIncidence;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The angle of refraction, in degrees.
|
||||||
|
*/
|
||||||
|
double angleOfRefraction;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructor. Is the only way to set the values of the angles of incidence
|
||||||
|
* and refraction. The index of refraction is calculated.
|
||||||
|
*
|
||||||
|
* @param angleOfRefractionIn The angle of refraction, in degrees.
|
||||||
|
*
|
||||||
|
* @param angleOfIncidenceIn The angle of incidence, in degrees.
|
||||||
|
*/
|
||||||
|
public IndexOfRefractionReading(double angleOfRefractionIn, double angleOfIncidenceIn) {
|
||||||
|
angleOfIncidence = angleOfIncidenceIn;
|
||||||
|
angleOfRefraction = angleOfRefractionIn;
|
||||||
|
|
||||||
|
try {
|
||||||
|
indexOfRefraction = angleOfIncidence / angleOfRefraction;
|
||||||
|
} catch (ArithmeticException e) {
|
||||||
|
indexOfRefraction = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
System.out.println("Refractive index reading stored successfully.\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the angle of incidence, of the same data type it is stored as (double).
|
||||||
|
*/
|
||||||
|
public double getAngleOfIncidence() {
|
||||||
|
return angleOfIncidence;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the angle of refraction, of the same data type it is stored as (double).
|
||||||
|
*/
|
||||||
|
public double getAngleOfRefraction() {
|
||||||
|
return angleOfRefraction;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the index of refraction, of the same data type it is stored as (double).
|
||||||
|
*/
|
||||||
|
public double getIndexOfRefraction() {
|
||||||
|
return indexOfRefraction;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
String reading = "Refractive Index Reading:\n"
|
||||||
|
+ " Angle of Incidence: " + angleOfIncidence + "°\n"
|
||||||
|
+ " Recorded Angle of Refraction: " + angleOfRefraction + "°\n"
|
||||||
|
+ " Determined Refractive Index: ";
|
||||||
|
|
||||||
|
if (indexOfRefraction == 0)
|
||||||
|
reading += "Undefined";
|
||||||
|
else
|
||||||
|
reading += indexOfRefraction;
|
||||||
|
|
||||||
|
reading += "\n";
|
||||||
|
|
||||||
|
return reading;
|
||||||
|
}
|
||||||
|
}
|
66
src/seabedexplorer/data/LaserReading.java
Normal file
66
src/seabedexplorer/data/LaserReading.java
Normal file
@ -0,0 +1,66 @@
|
|||||||
|
|
||||||
|
package seabedexplorer.data;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* LaserReading. Stores an angle, as recorded by a laser camera, as well as a
|
||||||
|
* distance that is a useful property of the laser camera itself.
|
||||||
|
*
|
||||||
|
* @author Dan Lawrence
|
||||||
|
* @version %I%, %G%
|
||||||
|
*/
|
||||||
|
public class LaserReading extends TopographicalMapping{
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The recorded angle, in degrees.
|
||||||
|
*/
|
||||||
|
double angle;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The distance between the camera and the laser, in meters.
|
||||||
|
*/
|
||||||
|
double distance;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructor. Is the only way to set the values of the reading, and the
|
||||||
|
* distance.
|
||||||
|
*
|
||||||
|
* @param angleIn The recorded angle, in degrees.
|
||||||
|
*
|
||||||
|
* @param distanceIn The distance between the camera and the laser, in
|
||||||
|
* meters.
|
||||||
|
*/
|
||||||
|
public LaserReading(double angleIn, double distanceIn) {
|
||||||
|
angle = angleIn;
|
||||||
|
distance = distanceIn;
|
||||||
|
|
||||||
|
calculateDepth();
|
||||||
|
|
||||||
|
System.out.println("Laser camera depth reading stored successfully.\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
void calculateDepth() {
|
||||||
|
depth = distance / Math.tan(angle / (180/Math.PI));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the angle, of the same data type it is stored as (double).
|
||||||
|
*/
|
||||||
|
public double getAngle() {
|
||||||
|
return angle;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the distance, of the same data type it is stored as (double).
|
||||||
|
*/
|
||||||
|
public double getDistance() {
|
||||||
|
return distance;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return "Laser camera reading:\n"
|
||||||
|
+ " Recorded angle: " + angle + "°\n"
|
||||||
|
+ " Determined depth: " + depth + "m\n";
|
||||||
|
}
|
||||||
|
}
|
74
src/seabedexplorer/data/MaterialSample.java
Normal file
74
src/seabedexplorer/data/MaterialSample.java
Normal file
@ -0,0 +1,74 @@
|
|||||||
|
package seabedexplorer.data;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* MaterialSample. Stores the mass, and volume of a material sample, as
|
||||||
|
* collected by a piece of material sampling equipment.
|
||||||
|
*
|
||||||
|
* @author Dan Lawrence
|
||||||
|
*/
|
||||||
|
public class MaterialSample implements Data
|
||||||
|
{
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Volume of the sample, in meters cubed. Is dependant entirely on the
|
||||||
|
* capacity of the sampler.
|
||||||
|
*/
|
||||||
|
double volume;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Mass of the sample, in kilograms.
|
||||||
|
*/
|
||||||
|
double mass;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Density of the sample, in kg/m³.
|
||||||
|
*/
|
||||||
|
double density;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructor. Is the only way to set the values for mass and volume. The
|
||||||
|
* value of density is calculated, so cannot be set manually.
|
||||||
|
*
|
||||||
|
* @param volumeIn Volume of the sample, in meters cubed. Is dependant entirely on the
|
||||||
|
* capacity of the sampler.
|
||||||
|
*
|
||||||
|
* @param massIn Mass of the sample, in kilograms.
|
||||||
|
*/
|
||||||
|
public MaterialSample(double volumeIn, double massIn) {
|
||||||
|
volume = volumeIn;
|
||||||
|
mass = massIn;
|
||||||
|
|
||||||
|
density = mass/volume;
|
||||||
|
|
||||||
|
System.out.println("Material sample collected successfully.\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the volume, of the same data type it is stored as (double).
|
||||||
|
*/
|
||||||
|
public double getVolume() {
|
||||||
|
return volume;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the mass, of the same data type it is stored as (double).
|
||||||
|
*/
|
||||||
|
public double getMass() {
|
||||||
|
return mass;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the density, of the same data type it is stored as (double).
|
||||||
|
*/
|
||||||
|
public double getDensity() {
|
||||||
|
return density;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return "Material sample:\n"
|
||||||
|
+ " Volume of sample: " + volume + "m³\n"
|
||||||
|
+ " Recorded mass of sample: " + mass + "kg\n"
|
||||||
|
+ " Determined density of sample: " + density + "kg/m³\n";
|
||||||
|
}
|
||||||
|
}
|
51
src/seabedexplorer/data/PhotoSensorReading.java
Normal file
51
src/seabedexplorer/data/PhotoSensorReading.java
Normal file
@ -0,0 +1,51 @@
|
|||||||
|
package seabedexplorer.data;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* PhotoSensorReading. Stores a wavelength, as recorded by a photo-sensor.
|
||||||
|
*
|
||||||
|
* @author Dan Lawrence
|
||||||
|
*/
|
||||||
|
public class PhotoSensorReading implements Data
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* The wavelength of the detected EM radiation, in nanometres.
|
||||||
|
*/
|
||||||
|
double wavelength;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructor. Is the only way to set the value of the reading.
|
||||||
|
*
|
||||||
|
* @param wavelengthIn The wavelength of the detected EM radiation, in nanometres.
|
||||||
|
*/
|
||||||
|
public PhotoSensorReading(double wavelengthIn) {
|
||||||
|
wavelength = wavelengthIn;
|
||||||
|
|
||||||
|
System.out.println("Photo-sensor reading stored successfully.\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the wavelength, of the same data type as it is stored as (double).
|
||||||
|
*/
|
||||||
|
public double getReading() {
|
||||||
|
return wavelength;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
|
||||||
|
String reading = "Photosensor reading:\n"
|
||||||
|
+ " Recorded wavelength: " + wavelength + "nm\n"
|
||||||
|
+ " Type of EM radiation received: ";
|
||||||
|
|
||||||
|
if (wavelength < 400)
|
||||||
|
reading += "Ultra-Violet";
|
||||||
|
else if (wavelength > 700)
|
||||||
|
reading += "Infra-Red";
|
||||||
|
else
|
||||||
|
reading += "Visible light";
|
||||||
|
|
||||||
|
reading += "\n";
|
||||||
|
|
||||||
|
return reading;
|
||||||
|
}
|
||||||
|
}
|
40
src/seabedexplorer/data/SalinityReading.java
Normal file
40
src/seabedexplorer/data/SalinityReading.java
Normal file
@ -0,0 +1,40 @@
|
|||||||
|
|
||||||
|
package seabedexplorer.data;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* SalinityReading. Stores a recorded value of the salinity of the seawater.
|
||||||
|
*
|
||||||
|
* @author Dan Lawrence
|
||||||
|
*/
|
||||||
|
public class SalinityReading extends WaterReading {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The recorded salinity, in parts per thousand.
|
||||||
|
*/
|
||||||
|
double salinity;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructor. Is the only way to set the value of the recorded pH.
|
||||||
|
*
|
||||||
|
* @param salinityIn The recorded salinity, in parts per thousand.
|
||||||
|
*/
|
||||||
|
public SalinityReading(double salinityIn) {
|
||||||
|
salinity = salinityIn;
|
||||||
|
|
||||||
|
System.out.println("Salinity reading stored successfully.\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the salinity, of the same data type it is stored as (double).
|
||||||
|
*/
|
||||||
|
public double getReading() {
|
||||||
|
return salinity;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return "Salinity reading:\n"
|
||||||
|
+ " Recorded salinity: " + salinity + "ppt\n";
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
50
src/seabedexplorer/data/SonarReading.java
Normal file
50
src/seabedexplorer/data/SonarReading.java
Normal file
@ -0,0 +1,50 @@
|
|||||||
|
|
||||||
|
package seabedexplorer.data;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* SonarReading. Stores a response time, as recorded by a sonar
|
||||||
|
* emitter/receiver.
|
||||||
|
*
|
||||||
|
* @author Dan Lawrence
|
||||||
|
*/
|
||||||
|
public class SonarReading extends TopographicalMapping {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The recorded response time, in milliseconds.
|
||||||
|
*/
|
||||||
|
double responseTime;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructor. Is the only way to set a value for the response time
|
||||||
|
* reading.
|
||||||
|
*
|
||||||
|
* @param responseTimeIn The response time, as recorded by the sonar
|
||||||
|
* receiver.
|
||||||
|
*/
|
||||||
|
public SonarReading(double responseTimeIn) {
|
||||||
|
responseTime = responseTimeIn;
|
||||||
|
|
||||||
|
calculateDepth();
|
||||||
|
|
||||||
|
System.out.println("Sonar depth reading stored successfully.\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
void calculateDepth() {
|
||||||
|
depth = responseTime * 1.5;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the response time, of the same data type it is stored as (double)
|
||||||
|
*/
|
||||||
|
public double getReading() {
|
||||||
|
return responseTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return "Sonar reading:\n"
|
||||||
|
+ " Response time: " + responseTime + "ms\n"
|
||||||
|
+ " Determined depth: " + depth + "m\n";
|
||||||
|
}
|
||||||
|
}
|
27
src/seabedexplorer/data/TopographicalMapping.java
Normal file
27
src/seabedexplorer/data/TopographicalMapping.java
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
package seabedexplorer.data;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* TopographicalMapping. Holds some common data and behaviour between
|
||||||
|
* LaserReading and SonarReading
|
||||||
|
*
|
||||||
|
* @author Dan Lawrence
|
||||||
|
*/
|
||||||
|
public abstract class TopographicalMapping implements Data
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* The calculated depth of the seabed, in meters.
|
||||||
|
*/
|
||||||
|
double depth;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Calculates the depth of the seabed using the stored readings.
|
||||||
|
*/
|
||||||
|
abstract void calculateDepth();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the depth, of the same data type it is stored as (double).
|
||||||
|
*/
|
||||||
|
public double getDepth() {
|
||||||
|
return depth;
|
||||||
|
}
|
||||||
|
}
|
11
src/seabedexplorer/data/WaterReading.java
Normal file
11
src/seabedexplorer/data/WaterReading.java
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
package seabedexplorer.data;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* WaterReading
|
||||||
|
*
|
||||||
|
* @author Dan Lawrence.
|
||||||
|
*/
|
||||||
|
public abstract class WaterReading implements Data
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
51
src/seabedexplorer/data/pHReading.java
Normal file
51
src/seabedexplorer/data/pHReading.java
Normal file
@ -0,0 +1,51 @@
|
|||||||
|
|
||||||
|
package seabedexplorer.data;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* pHReading. Stores a recorded value for the pH of the seawater.
|
||||||
|
*
|
||||||
|
* @author Dan Lawrence
|
||||||
|
*/
|
||||||
|
public class pHReading extends WaterReading {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The recorded pH.
|
||||||
|
*/
|
||||||
|
double pH;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructor. Is the only way to set the value of the recorded pH.
|
||||||
|
*
|
||||||
|
* @param pHIn The recorded pH.
|
||||||
|
*/
|
||||||
|
public pHReading(double pHIn) {
|
||||||
|
pH = pHIn;
|
||||||
|
|
||||||
|
System.out.println("Seawater pH reading stored successfully.\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the pH, of the same data type it is stored as (double).
|
||||||
|
*/
|
||||||
|
public double getReading() {
|
||||||
|
return pH;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
String reading = "pH Reading:\n"
|
||||||
|
+ " Recorded pH: " + pH + "\n"
|
||||||
|
+ " Acid or Alkali: ";
|
||||||
|
|
||||||
|
if (pH < 7)
|
||||||
|
reading += "Acid";
|
||||||
|
else if (pH > 7)
|
||||||
|
reading += "Alkali";
|
||||||
|
else
|
||||||
|
reading += "Neither";
|
||||||
|
|
||||||
|
reading += "\n";
|
||||||
|
|
||||||
|
return reading;
|
||||||
|
}
|
||||||
|
}
|
18
src/seabedexplorer/observer/Observer.java
Normal file
18
src/seabedexplorer/observer/Observer.java
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
package seabedexplorer.observer;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* An Observer interface created to facilitate the implementation of the Observer design pattern between Vessels and Submersibles.
|
||||||
|
*
|
||||||
|
* @author Dylan Currey
|
||||||
|
* @since 01/11/18
|
||||||
|
*/
|
||||||
|
public interface Observer {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Updates the Observer with the specified command
|
||||||
|
* @param cmd the passed command
|
||||||
|
*/
|
||||||
|
public boolean update(String cmd);
|
||||||
|
|
||||||
|
}
|
38
src/seabedexplorer/observer/Subject.java
Normal file
38
src/seabedexplorer/observer/Subject.java
Normal file
@ -0,0 +1,38 @@
|
|||||||
|
package seabedexplorer.observer;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collection;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A Subject interface created to facilitate the implementation of the Observer design pattern between Vessels and Submersibles.
|
||||||
|
*
|
||||||
|
* @author Dylan Currey
|
||||||
|
* @since 01/11/18
|
||||||
|
*/
|
||||||
|
public interface Subject
|
||||||
|
{
|
||||||
|
|
||||||
|
/**
|
||||||
|
* An ArrayList containing all observers attached to the concrete subject.
|
||||||
|
*/
|
||||||
|
Collection<Observer> listOfObservers = new ArrayList<>();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Attaches observers to the subject.
|
||||||
|
* @param observer the <i>Observer</i> object to be attached.
|
||||||
|
*/
|
||||||
|
public void attach(Observer observer);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Detaches observers from the subject
|
||||||
|
* @param observer the <i>Observer</i> object to be detached
|
||||||
|
*/
|
||||||
|
public void detach (Observer observer);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Updates all observers in <i>listOfObservers</i> with a command.
|
||||||
|
* @param cmd the command sent.
|
||||||
|
*/
|
||||||
|
public boolean updateObservers(String cmd);
|
||||||
|
|
||||||
|
}
|
58
src/seabedexplorer/submersible/AUV.java
Normal file
58
src/seabedexplorer/submersible/AUV.java
Normal file
@ -0,0 +1,58 @@
|
|||||||
|
package seabedexplorer.submersible;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import seabedexplorer.submersible.state.states.DockedState;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* AUV (Automated Underwater Vehicle) (A type of submersible)
|
||||||
|
*
|
||||||
|
* @author JLScott1999
|
||||||
|
*/
|
||||||
|
public final class AUV extends Submersible
|
||||||
|
{
|
||||||
|
|
||||||
|
private static final String TYPE = "AUV (Automated Underwater Vehicle)";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructor
|
||||||
|
*/
|
||||||
|
public AUV()
|
||||||
|
{
|
||||||
|
super(new ArrayList<>());
|
||||||
|
changeState(new DockedState());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns this object
|
||||||
|
* @return <i>Submersible</i> object
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public Submersible getSubmersible()
|
||||||
|
{
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void collectData()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean update(String cmd) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getSubmersibleType()
|
||||||
|
{
|
||||||
|
return TYPE;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString()
|
||||||
|
{
|
||||||
|
return "Type: " + TYPE + "\n" + super.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
58
src/seabedexplorer/submersible/MS.java
Normal file
58
src/seabedexplorer/submersible/MS.java
Normal file
@ -0,0 +1,58 @@
|
|||||||
|
package seabedexplorer.submersible;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import seabedexplorer.submersible.state.states.DockedState;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* MS (Manned Submersible) (A type of submersible)
|
||||||
|
*
|
||||||
|
* @author JLScott1999
|
||||||
|
*/
|
||||||
|
public final class MS extends Submersible
|
||||||
|
{
|
||||||
|
|
||||||
|
private static final String TYPE = "MS (Manned Submersible)";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructor
|
||||||
|
*/
|
||||||
|
public MS()
|
||||||
|
{
|
||||||
|
super(new ArrayList<>());
|
||||||
|
changeState(new DockedState());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns this object
|
||||||
|
* @return <i>Submersible</i> object
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public Submersible getSubmersible()
|
||||||
|
{
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void collectData()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean update(String cmd) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getSubmersibleType()
|
||||||
|
{
|
||||||
|
return TYPE;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString()
|
||||||
|
{
|
||||||
|
return "Type: " + TYPE + "\n" + super.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
15
src/seabedexplorer/submersible/Moveable.java
Normal file
15
src/seabedexplorer/submersible/Moveable.java
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
|
||||||
|
package seabedexplorer.submersible;
|
||||||
|
|
||||||
|
import seabedexplorer.submersible.equipment.locationtracking.Location;
|
||||||
|
|
||||||
|
public interface Moveable {
|
||||||
|
|
||||||
|
Location currentLocation = null;
|
||||||
|
|
||||||
|
public void move(Location loc);
|
||||||
|
public void stopMove();
|
||||||
|
public boolean canMove();
|
||||||
|
public boolean returnToVessel();
|
||||||
|
|
||||||
|
}
|
58
src/seabedexplorer/submersible/ROV.java
Normal file
58
src/seabedexplorer/submersible/ROV.java
Normal file
@ -0,0 +1,58 @@
|
|||||||
|
package seabedexplorer.submersible;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import seabedexplorer.submersible.state.states.DockedState;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ROV (Remote Operated Vehicle) (A type of submersible)
|
||||||
|
*
|
||||||
|
* @author JLScott1999
|
||||||
|
*/
|
||||||
|
public final class ROV extends Submersible
|
||||||
|
{
|
||||||
|
|
||||||
|
private static final String TYPE = "ROV (Remote Operated Vehicle)";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructor
|
||||||
|
*/
|
||||||
|
public ROV()
|
||||||
|
{
|
||||||
|
super(new ArrayList<>());
|
||||||
|
changeState(new DockedState());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns this object
|
||||||
|
* @return <i>Submersible</i> object
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public Submersible getSubmersible()
|
||||||
|
{
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void collectData()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean update(String cmd) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getSubmersibleType()
|
||||||
|
{
|
||||||
|
return TYPE;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString()
|
||||||
|
{
|
||||||
|
return "Type: " + TYPE + "\n" + super.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
182
src/seabedexplorer/submersible/Submersible.java
Normal file
182
src/seabedexplorer/submersible/Submersible.java
Normal file
@ -0,0 +1,182 @@
|
|||||||
|
package seabedexplorer.submersible;
|
||||||
|
|
||||||
|
import java.util.Collection;
|
||||||
|
import seabedexplorer.data.Data;
|
||||||
|
import seabedexplorer.observer.Observer;
|
||||||
|
import seabedexplorer.submersible.equipment.locationtracking.GPS;
|
||||||
|
import seabedexplorer.submersible.equipment.locationtracking.Location;
|
||||||
|
import seabedexplorer.submersible.state.SubmersibleState;
|
||||||
|
import seabedexplorer.submersible.state.states.DockedState;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Submersible
|
||||||
|
*
|
||||||
|
* @author JLScott1999
|
||||||
|
*/
|
||||||
|
public abstract class Submersible implements Observer, Moveable
|
||||||
|
{
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Data storage for the submarine
|
||||||
|
*/
|
||||||
|
protected Collection<Data> dataCollection;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* State of the submersible
|
||||||
|
*/
|
||||||
|
private SubmersibleState currentState;
|
||||||
|
|
||||||
|
private GPS gps;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructor creating a submersible with some type of data storage eg) ArrayList or LinkedList
|
||||||
|
* @param dataCollection the data storage to use eg) ArrayList or LinkedList
|
||||||
|
*/
|
||||||
|
public Submersible(Collection<Data> dataCollection)
|
||||||
|
{
|
||||||
|
this.dataCollection = dataCollection;
|
||||||
|
gps = new GPS();
|
||||||
|
currentState = new DockedState();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructor creating a submersible without any data storage state or gps
|
||||||
|
*/
|
||||||
|
public Submersible()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the submersible object
|
||||||
|
* @return submersible object memory address
|
||||||
|
*/
|
||||||
|
public abstract Submersible getSubmersible();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the submersible type
|
||||||
|
* @return submersible type such as AUV, ROV, etc..
|
||||||
|
*/
|
||||||
|
public abstract String getSubmersibleType();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Collect data using one of the equipment provided
|
||||||
|
*/
|
||||||
|
public abstract void collectData();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the data stored on the submersible
|
||||||
|
* @return the data stored on the submersible
|
||||||
|
*/
|
||||||
|
public Collection<Data> getData() {
|
||||||
|
return dataCollection;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add data to store on the submersible
|
||||||
|
* @param data the data to store on the submersible
|
||||||
|
*/
|
||||||
|
public void addData(Data data)
|
||||||
|
{
|
||||||
|
if (data != null)
|
||||||
|
{
|
||||||
|
dataCollection.add(data);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Clear the data stored on a submersible
|
||||||
|
*/
|
||||||
|
public void clearData()
|
||||||
|
{
|
||||||
|
if (dataCollection != null)
|
||||||
|
{
|
||||||
|
dataCollection.removeAll(dataCollection);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void changeState(SubmersibleState state)
|
||||||
|
{
|
||||||
|
currentState = state;
|
||||||
|
state.submersibleInstance(this);
|
||||||
|
System.out.println("State Changed: " + currentState.toString());
|
||||||
|
}
|
||||||
|
|
||||||
|
public SubmersibleState getState()
|
||||||
|
{
|
||||||
|
return currentState;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getStateName()
|
||||||
|
{
|
||||||
|
return currentState.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void move(Location loc)
|
||||||
|
{
|
||||||
|
currentState.move(loc);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void stopMove()
|
||||||
|
{
|
||||||
|
currentState.stopMove();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean canMove()
|
||||||
|
{
|
||||||
|
return currentState.canMove();
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean returnToVessel()
|
||||||
|
{
|
||||||
|
return currentState.returnToVessel();
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean collectWater()
|
||||||
|
{
|
||||||
|
return currentState.collectWater();
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean collectMaterial()
|
||||||
|
{
|
||||||
|
return currentState.collectMaterial();
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean collectMappingData()
|
||||||
|
{
|
||||||
|
return currentState.collectMappingData();
|
||||||
|
}
|
||||||
|
|
||||||
|
public GPS getGPS()
|
||||||
|
{
|
||||||
|
return gps;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setGPS(GPS gps)
|
||||||
|
{
|
||||||
|
this.gps = gps;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString()
|
||||||
|
{
|
||||||
|
String result = "";
|
||||||
|
if (currentState != null)
|
||||||
|
{
|
||||||
|
result += "State: " + currentState.toString() + "\n";
|
||||||
|
}
|
||||||
|
if (dataCollection != null)
|
||||||
|
{
|
||||||
|
result += "Data:";
|
||||||
|
for (Data d: dataCollection)
|
||||||
|
{
|
||||||
|
result += "\n " + d.toString().replace("\n", "\n ");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return result + "\nEquipment:";
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
165
src/seabedexplorer/submersible/equipment/Equipment.java
Normal file
165
src/seabedexplorer/submersible/equipment/Equipment.java
Normal file
@ -0,0 +1,165 @@
|
|||||||
|
package seabedexplorer.submersible.equipment;
|
||||||
|
|
||||||
|
import java.util.Collection;
|
||||||
|
import seabedexplorer.data.Data;
|
||||||
|
import seabedexplorer.submersible.Submersible;
|
||||||
|
import seabedexplorer.submersible.equipment.datacollector.DataCollector;
|
||||||
|
import seabedexplorer.submersible.equipment.locationtracking.GPS;
|
||||||
|
import seabedexplorer.submersible.equipment.locationtracking.Location;
|
||||||
|
import seabedexplorer.submersible.state.SubmersibleState;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Equipment
|
||||||
|
*
|
||||||
|
* @author JLScott1999
|
||||||
|
*/
|
||||||
|
public abstract class Equipment extends Submersible
|
||||||
|
{
|
||||||
|
|
||||||
|
private Submersible submersible;
|
||||||
|
private final DataCollector dataCollector;
|
||||||
|
|
||||||
|
public Equipment(Submersible submersible, DataCollector dataCollector)
|
||||||
|
{
|
||||||
|
this.submersible = submersible;
|
||||||
|
this.dataCollector = dataCollector;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void setSubmersible(Submersible submersible)
|
||||||
|
{
|
||||||
|
this.submersible = submersible;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Submersible getSubmersible()
|
||||||
|
{
|
||||||
|
return submersible;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getSubmersibleType()
|
||||||
|
{
|
||||||
|
return submersible.getSubmersibleType();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void addData(Data data)
|
||||||
|
{
|
||||||
|
submersible.addData(data);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void collectData()
|
||||||
|
{
|
||||||
|
addData(dataCollector.performReading());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Collection<Data> getData() {
|
||||||
|
return submersible.getData();
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean collectWater()
|
||||||
|
{
|
||||||
|
return submersible.collectWater();
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean collectMaterial()
|
||||||
|
{
|
||||||
|
return submersible.collectMaterial();
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean collectMappingData()
|
||||||
|
{
|
||||||
|
return submersible.collectMappingData();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void clearData()
|
||||||
|
{
|
||||||
|
submersible.clearData();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void changeState(SubmersibleState state)
|
||||||
|
{
|
||||||
|
submersible.changeState(state);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public SubmersibleState getState()
|
||||||
|
{
|
||||||
|
return submersible.getState();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getStateName()
|
||||||
|
{
|
||||||
|
return submersible.getStateName();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void move(Location loc)
|
||||||
|
{
|
||||||
|
submersible.move(loc);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void stopMove()
|
||||||
|
{
|
||||||
|
submersible.stopMove();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean canMove()
|
||||||
|
{
|
||||||
|
return submersible.canMove();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean returnToVessel()
|
||||||
|
{
|
||||||
|
return submersible.returnToVessel();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public GPS getGPS()
|
||||||
|
{
|
||||||
|
return submersible.getGPS();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setGPS(GPS gps)
|
||||||
|
{
|
||||||
|
submersible.setGPS(gps);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean update(String cmd)
|
||||||
|
{
|
||||||
|
boolean result;
|
||||||
|
if (cmd.equalsIgnoreCase("all"))
|
||||||
|
{
|
||||||
|
collectData();
|
||||||
|
result = true;
|
||||||
|
submersible.update(cmd);
|
||||||
|
}
|
||||||
|
else if (cmd.equalsIgnoreCase("info"))
|
||||||
|
{
|
||||||
|
System.out.println(toString() + "\n");
|
||||||
|
result = true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
result = submersible.update(cmd);
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString()
|
||||||
|
{
|
||||||
|
return submersible.toString() + "\n ";
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
36
src/seabedexplorer/submersible/equipment/PhotoSensor.java
Normal file
36
src/seabedexplorer/submersible/equipment/PhotoSensor.java
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
package seabedexplorer.submersible.equipment;
|
||||||
|
|
||||||
|
import seabedexplorer.submersible.Submersible;
|
||||||
|
import seabedexplorer.submersible.equipment.datacollector.DCPhotoSensor;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author JLScott1999
|
||||||
|
*/
|
||||||
|
public class PhotoSensor extends Equipment
|
||||||
|
{
|
||||||
|
|
||||||
|
public PhotoSensor(Submersible drone)
|
||||||
|
{
|
||||||
|
super(drone, new DCPhotoSensor());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString()
|
||||||
|
{
|
||||||
|
return super.toString() + "Photo Sensor";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean update(String cmd) {
|
||||||
|
boolean result;
|
||||||
|
if(cmd.equalsIgnoreCase("photosensor")){
|
||||||
|
this.collectData();
|
||||||
|
result = true;
|
||||||
|
} else {
|
||||||
|
result = super.update(cmd);
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,47 @@
|
|||||||
|
package seabedexplorer.submersible.equipment.datacollector;
|
||||||
|
|
||||||
|
import java.util.concurrent.ThreadLocalRandom;
|
||||||
|
import seabedexplorer.data.PhotoSensorReading;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* PhotoSensor. Simulates the behaviour of a photo-sensor detecting
|
||||||
|
* Electro-Magnetic radiation, between Infra-Red and Ultra-Violet, and recording
|
||||||
|
* its wavelength.
|
||||||
|
*
|
||||||
|
* @author Dan Lawrence
|
||||||
|
*/
|
||||||
|
public class DCPhotoSensor implements DataCollector
|
||||||
|
{
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public PhotoSensorReading performReading()
|
||||||
|
{
|
||||||
|
System.out.println("Taking wavelength reading with photo sensor...");
|
||||||
|
|
||||||
|
double actualWavelength = ThreadLocalRandom.current().nextDouble(10,1000000);
|
||||||
|
|
||||||
|
double wavelength;
|
||||||
|
|
||||||
|
double lowBound = 0;
|
||||||
|
double highBound = 0;
|
||||||
|
|
||||||
|
if (ThreadLocalRandom.current().nextInt(0, 10) == 0)
|
||||||
|
wavelength = ThreadLocalRandom.current().nextDouble(10,1000000);
|
||||||
|
else {
|
||||||
|
|
||||||
|
if (0.9 * actualWavelength < 10)
|
||||||
|
lowBound = 10;
|
||||||
|
else if (1.1 * actualWavelength > 1000000)
|
||||||
|
highBound = 1000000;
|
||||||
|
else {
|
||||||
|
lowBound = 0.9 * actualWavelength;
|
||||||
|
highBound = 1.1 * actualWavelength;
|
||||||
|
}
|
||||||
|
|
||||||
|
wavelength = ThreadLocalRandom.current().nextDouble(lowBound,highBound);
|
||||||
|
}
|
||||||
|
|
||||||
|
return new PhotoSensorReading(wavelength);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,22 @@
|
|||||||
|
package seabedexplorer.submersible.equipment.datacollector;
|
||||||
|
|
||||||
|
import seabedexplorer.data.Data;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* DataCollector
|
||||||
|
*
|
||||||
|
* @author JLScott1999
|
||||||
|
*/
|
||||||
|
public interface DataCollector
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Simulates the process of the equipment taking whichever reading it is
|
||||||
|
* designed to take, and creates a new specialised Data object to store it.
|
||||||
|
*
|
||||||
|
* @return A specialised Data object, that contains the reading that was
|
||||||
|
* taken, alongside any variables which need to be specified, if any, and
|
||||||
|
* any useful values calculated using the reading, if any.
|
||||||
|
*/
|
||||||
|
public Data performReading();
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,14 @@
|
|||||||
|
package seabedexplorer.submersible.equipment.datacollector.materialsampler;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* DCChemicalScanner. Currently, data is generated in the same way as any other
|
||||||
|
* material sampler.
|
||||||
|
*
|
||||||
|
* @author Dan Lawrence
|
||||||
|
*/
|
||||||
|
public class DCChemicalScanner extends DCMaterialSampler
|
||||||
|
{
|
||||||
|
public DCChemicalScanner(double volumeIn) {
|
||||||
|
super(volumeIn);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,14 @@
|
|||||||
|
package seabedexplorer.submersible.equipment.datacollector.materialsampler;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* DCHotFluidSampler. Currently, data is generated in the same way as any other
|
||||||
|
* material sampler.
|
||||||
|
*
|
||||||
|
* @author Dan Lawrence
|
||||||
|
*/
|
||||||
|
public class DCHotFluidSampler extends DCMaterialSampler
|
||||||
|
{
|
||||||
|
public DCHotFluidSampler(double volumeIn) {
|
||||||
|
super(volumeIn);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,48 @@
|
|||||||
|
package seabedexplorer.submersible.equipment.datacollector.materialsampler;
|
||||||
|
|
||||||
|
import java.util.concurrent.ThreadLocalRandom;
|
||||||
|
import seabedexplorer.data.Data;
|
||||||
|
import seabedexplorer.data.MaterialSample;
|
||||||
|
import seabedexplorer.submersible.equipment.datacollector.DataCollector;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* DCMaterialSampler. Simulates the behaviour of a material sample of a
|
||||||
|
* specified volume being collected, and having its mass recorded.
|
||||||
|
*
|
||||||
|
* @author Dan Lawrence
|
||||||
|
*/
|
||||||
|
public abstract class DCMaterialSampler implements DataCollector
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* The volume of the sample, in m³. Determined by the capacity of the
|
||||||
|
* equipment.
|
||||||
|
*/
|
||||||
|
double volume;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructor. Used to transfer the capacity of the equipment into this
|
||||||
|
* class, so it can be passed into the reading.
|
||||||
|
* @param volumeIn - The sample capacity of the equipment.
|
||||||
|
*/
|
||||||
|
public DCMaterialSampler(double volumeIn) {
|
||||||
|
volume = volumeIn;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Data performReading() {
|
||||||
|
System.out.println("Collecting material sample, of volume " + volume + "m³...");
|
||||||
|
|
||||||
|
double actualDensity = ThreadLocalRandom.current().nextDouble(0, 22500);
|
||||||
|
double actualMass = actualDensity * volume;
|
||||||
|
|
||||||
|
double mass;
|
||||||
|
|
||||||
|
if (ThreadLocalRandom.current().nextInt(0, 10) == 0)
|
||||||
|
mass = ThreadLocalRandom.current().nextDouble(0,25000);
|
||||||
|
else
|
||||||
|
mass = ThreadLocalRandom.current().nextDouble(0.9 * actualMass, 1.1 * actualMass);
|
||||||
|
|
||||||
|
return new MaterialSample(volume,mass);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,14 @@
|
|||||||
|
package seabedexplorer.submersible.equipment.datacollector.materialsampler;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* DCRockCoringDrill. Currently, data is generated in the same way as any other
|
||||||
|
* material sampler.
|
||||||
|
*
|
||||||
|
* @author Dan Lawrence
|
||||||
|
*/
|
||||||
|
public class DCRockCoringDrill extends DCMaterialSampler
|
||||||
|
{
|
||||||
|
public DCRockCoringDrill(double volumeIn) {
|
||||||
|
super(volumeIn);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,52 @@
|
|||||||
|
package seabedexplorer.submersible.equipment.datacollector.topographicalmapper;
|
||||||
|
|
||||||
|
import java.util.concurrent.ThreadLocalRandom;
|
||||||
|
import seabedexplorer.data.LaserReading;
|
||||||
|
import seabedexplorer.data.TopographicalMapping;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* DCLaser. Simulates the behaviour of a laser camera, with a specified distance
|
||||||
|
* between the camera, and the emitter. An angle is recorded, and is used in a
|
||||||
|
* trigonometric function to calculate the depth of the seabed, at the point
|
||||||
|
* that the laser landed.
|
||||||
|
*
|
||||||
|
* @author Dan Lawrence
|
||||||
|
*/
|
||||||
|
public class DCLaser implements DCTopographicalMapper
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* The distance between the camera, and the laser emitter, in meters.
|
||||||
|
*/
|
||||||
|
double distance;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructor. Used to transfer the distance into this class, so it can be
|
||||||
|
* passed into the reading.
|
||||||
|
*
|
||||||
|
* @param distanceIn The distance between the camera, and the laser emitter,
|
||||||
|
* in meters.
|
||||||
|
*/
|
||||||
|
public DCLaser(double distanceIn) {
|
||||||
|
distance = distanceIn;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public TopographicalMapping performReading()
|
||||||
|
{
|
||||||
|
System.out.println("Taking depth reading with laser camera, distance of "
|
||||||
|
+ distance + "m between camera, and emitter...");
|
||||||
|
|
||||||
|
double actualDepth = ThreadLocalRandom.current().nextDouble(0,10000);
|
||||||
|
double actualAngle = (180/Math.PI) * Math.atan(distance / actualDepth);
|
||||||
|
|
||||||
|
double angle;
|
||||||
|
|
||||||
|
if (ThreadLocalRandom.current().nextInt(0, 10) == 0)
|
||||||
|
angle = ThreadLocalRandom.current().nextDouble(0,90);
|
||||||
|
else
|
||||||
|
angle = ThreadLocalRandom.current().nextDouble(0.9 * actualAngle, 1.1 * actualAngle);
|
||||||
|
|
||||||
|
return new LaserReading(angle,distance);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,37 @@
|
|||||||
|
package seabedexplorer.submersible.equipment.datacollector.topographicalmapper;
|
||||||
|
|
||||||
|
import java.util.concurrent.ThreadLocalRandom;
|
||||||
|
import seabedexplorer.data.SonarReading;
|
||||||
|
import seabedexplorer.data.TopographicalMapping;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* DCSonar. Simulates the behaviour of a sonar emitter/receiver sending a signal
|
||||||
|
* towards the seabed, so it can estimate the depth of the sea at that point.
|
||||||
|
*
|
||||||
|
* @author Dan Lawrence
|
||||||
|
*/
|
||||||
|
public class DCSonar implements DCTopographicalMapper
|
||||||
|
{
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public TopographicalMapping performReading()
|
||||||
|
{
|
||||||
|
System.out.println("Taking depth reading with sonar emitter/receiver...");
|
||||||
|
|
||||||
|
double actualDepth = ThreadLocalRandom.current().nextDouble(0,10000);
|
||||||
|
double actualResponseTime = actualDepth / 1.5;
|
||||||
|
|
||||||
|
double responseTime;
|
||||||
|
|
||||||
|
if (ThreadLocalRandom.current().nextInt(0, 10) == 0)
|
||||||
|
responseTime = ThreadLocalRandom.current().nextDouble(10000);
|
||||||
|
else
|
||||||
|
responseTime = ThreadLocalRandom
|
||||||
|
.current()
|
||||||
|
.nextDouble(0.9 * actualResponseTime, 1.1* actualResponseTime);
|
||||||
|
|
||||||
|
return new SonarReading(responseTime);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,13 @@
|
|||||||
|
package seabedexplorer.submersible.equipment.datacollector.topographicalmapper;
|
||||||
|
|
||||||
|
import seabedexplorer.submersible.equipment.datacollector.DataCollector;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* DCTopographicalMapper
|
||||||
|
*
|
||||||
|
* @author JLScott1999
|
||||||
|
*/
|
||||||
|
public interface DCTopographicalMapper extends DataCollector
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,42 @@
|
|||||||
|
package seabedexplorer.submersible.equipment.datacollector.waterreadings;
|
||||||
|
|
||||||
|
import java.util.concurrent.ThreadLocalRandom;
|
||||||
|
import seabedexplorer.data.IndexOfRefractionReading;
|
||||||
|
import seabedexplorer.data.WaterReading;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* DCIndexOfRefraction. Generates an angle of refraction, using a given angle of
|
||||||
|
* incidence, and stores the reading in a specialised Data class.
|
||||||
|
*
|
||||||
|
* @author Dan Lawrence
|
||||||
|
*/
|
||||||
|
public class DCIndexOfRefraction implements DCWaterReadings
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* The angle of incidence, i.e. the angle at which the ray of light enters
|
||||||
|
* the water.
|
||||||
|
*/
|
||||||
|
double angleOfIncidence;
|
||||||
|
|
||||||
|
public DCIndexOfRefraction(double angleOfIncidenceIn) {
|
||||||
|
angleOfIncidence = angleOfIncidenceIn;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public WaterReading performReading()
|
||||||
|
{
|
||||||
|
System.out.println("Taking a refraction index reading of the seawater; incidence angle of "
|
||||||
|
+ angleOfIncidence + "°...");
|
||||||
|
|
||||||
|
double actualAngleOfRefraction = angleOfIncidence / 1.38;
|
||||||
|
|
||||||
|
double AngleOfRefraction;
|
||||||
|
|
||||||
|
if (ThreadLocalRandom.current().nextInt(0, 10) == 0)
|
||||||
|
AngleOfRefraction = ThreadLocalRandom.current().nextDouble(0,90);
|
||||||
|
else
|
||||||
|
AngleOfRefraction = ThreadLocalRandom.current().nextDouble(0.9 * actualAngleOfRefraction, 1.1 * actualAngleOfRefraction);
|
||||||
|
|
||||||
|
return new IndexOfRefractionReading(AngleOfRefraction, angleOfIncidence);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,32 @@
|
|||||||
|
package seabedexplorer.submersible.equipment.datacollector.waterreadings;
|
||||||
|
|
||||||
|
import java.util.concurrent.ThreadLocalRandom;
|
||||||
|
import seabedexplorer.data.pHReading;
|
||||||
|
import seabedexplorer.data.WaterReading;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* DCPH. Simulates the behaviour of a pH strip. A pH is recorded, within the
|
||||||
|
* real pH range of seawater (7.5, 8.4), and the result saved to a specialised
|
||||||
|
* Data class.
|
||||||
|
*
|
||||||
|
* @author Dan Lawrence
|
||||||
|
*/
|
||||||
|
public class DCPH implements DCWaterReadings
|
||||||
|
{
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public WaterReading performReading()
|
||||||
|
{
|
||||||
|
System.out.println("Taking pH reading of the seawater, with a pH strip...");
|
||||||
|
|
||||||
|
double pH;
|
||||||
|
|
||||||
|
if (ThreadLocalRandom.current().nextInt(0, 10) == 0)
|
||||||
|
pH = ThreadLocalRandom.current().nextDouble(1,14);
|
||||||
|
else
|
||||||
|
pH = ThreadLocalRandom.current().nextDouble(7.5, 8.4);
|
||||||
|
|
||||||
|
return new pHReading(pH);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,33 @@
|
|||||||
|
package seabedexplorer.submersible.equipment.datacollector.waterreadings;
|
||||||
|
|
||||||
|
import java.util.concurrent.ThreadLocalRandom;
|
||||||
|
import seabedexplorer.data.SalinityReading;
|
||||||
|
import seabedexplorer.data.WaterReading;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* DCSalinity. Generates a value for the recorded salinity, close to the actual
|
||||||
|
* salinity of seawater, and stores it in a specialised Data class.
|
||||||
|
*
|
||||||
|
* @author Dan Lawrence
|
||||||
|
*/
|
||||||
|
public class DCSalinity implements DCWaterReadings
|
||||||
|
{
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public WaterReading performReading()
|
||||||
|
{
|
||||||
|
System.out.println("Taking salinity reading of the seawater...");
|
||||||
|
|
||||||
|
double actualSalinity = 35;
|
||||||
|
|
||||||
|
double Salinity;
|
||||||
|
|
||||||
|
if (ThreadLocalRandom.current().nextInt(0, 10) == 0)
|
||||||
|
Salinity = ThreadLocalRandom.current().nextDouble(0,1000);
|
||||||
|
else
|
||||||
|
Salinity = ThreadLocalRandom.current().nextDouble(0.9 * actualSalinity, 1.1 * actualSalinity);
|
||||||
|
|
||||||
|
return new SalinityReading(Salinity);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,13 @@
|
|||||||
|
package seabedexplorer.submersible.equipment.datacollector.waterreadings;
|
||||||
|
|
||||||
|
import seabedexplorer.submersible.equipment.datacollector.DataCollector;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* DCWaterReadings
|
||||||
|
*
|
||||||
|
* @author JLScott1999
|
||||||
|
*/
|
||||||
|
public interface DCWaterReadings extends DataCollector
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,23 @@
|
|||||||
|
package seabedexplorer.submersible.equipment.locationtracking;
|
||||||
|
|
||||||
|
public class GPS {
|
||||||
|
private Location currentLocation;
|
||||||
|
|
||||||
|
public GPS()
|
||||||
|
{
|
||||||
|
currentLocation = new Location(0, 0, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
//Getter
|
||||||
|
public Location getCurrentLocation()
|
||||||
|
{
|
||||||
|
return currentLocation;
|
||||||
|
}
|
||||||
|
|
||||||
|
//Setter
|
||||||
|
public void setCurrentLocation(Location location)
|
||||||
|
{
|
||||||
|
currentLocation = location;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,60 @@
|
|||||||
|
package seabedexplorer.submersible.equipment.locationtracking;
|
||||||
|
|
||||||
|
public class Location {
|
||||||
|
|
||||||
|
private int posX, posY, posZ;
|
||||||
|
|
||||||
|
//Constructors
|
||||||
|
public Location()
|
||||||
|
{
|
||||||
|
posX = 0;
|
||||||
|
posY = 0;
|
||||||
|
posZ = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Location(int x, int y, int z)
|
||||||
|
{
|
||||||
|
posX = x;
|
||||||
|
posY = y;
|
||||||
|
posZ = z;
|
||||||
|
}
|
||||||
|
|
||||||
|
//Getters
|
||||||
|
public int getPosX()
|
||||||
|
{
|
||||||
|
return posX;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getPosY()
|
||||||
|
{
|
||||||
|
return posY;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getPosZ()
|
||||||
|
{
|
||||||
|
return posZ;
|
||||||
|
}
|
||||||
|
|
||||||
|
//Setters
|
||||||
|
public void setPosX(int x)
|
||||||
|
{
|
||||||
|
posX = x;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPosY(int y)
|
||||||
|
{
|
||||||
|
posY = y;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPosZ(int z)
|
||||||
|
{
|
||||||
|
posZ = z;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString()
|
||||||
|
{
|
||||||
|
//Format: X, Y, Z
|
||||||
|
return Integer.toString(posX) + ", " + Integer.toString(posY) + ", " + Integer.toString(posZ);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,39 @@
|
|||||||
|
package seabedexplorer.submersible.equipment.materialsampler;
|
||||||
|
|
||||||
|
import seabedexplorer.submersible.Submersible;
|
||||||
|
import seabedexplorer.submersible.equipment.datacollector.materialsampler.DCChemicalScanner;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ChemicalScanner
|
||||||
|
*
|
||||||
|
* @author JLScott1999
|
||||||
|
*/
|
||||||
|
public class ChemicalScanner extends MaterialSampler
|
||||||
|
{
|
||||||
|
|
||||||
|
public ChemicalScanner(Submersible drone, double volumeIn)
|
||||||
|
{
|
||||||
|
super(drone, new DCChemicalScanner(volumeIn));
|
||||||
|
|
||||||
|
sampleVolume = volumeIn;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString()
|
||||||
|
{
|
||||||
|
return super.toString() + "Chemical Scanner";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean update(String cmd) {
|
||||||
|
boolean result;
|
||||||
|
if(cmd.equalsIgnoreCase("scan")){
|
||||||
|
this.collectData();
|
||||||
|
result = true;
|
||||||
|
} else {
|
||||||
|
result = super.update(cmd);
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,39 @@
|
|||||||
|
package seabedexplorer.submersible.equipment.materialsampler;
|
||||||
|
|
||||||
|
import seabedexplorer.submersible.Submersible;
|
||||||
|
import seabedexplorer.submersible.equipment.datacollector.materialsampler.DCHotFluidSampler;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* HotFluidSampler
|
||||||
|
*
|
||||||
|
* @author JLScott1999
|
||||||
|
*/
|
||||||
|
public class HotFluidSampler extends MaterialSampler
|
||||||
|
{
|
||||||
|
|
||||||
|
public HotFluidSampler(Submersible drone, double volumeIn)
|
||||||
|
{
|
||||||
|
super(drone, new DCHotFluidSampler(volumeIn));
|
||||||
|
|
||||||
|
sampleVolume = volumeIn;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString()
|
||||||
|
{
|
||||||
|
return super.toString() + "Hot Fluid Sampler";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean update(String cmd) {
|
||||||
|
boolean result;
|
||||||
|
if(cmd.equalsIgnoreCase("fluid")){
|
||||||
|
this.collectData();
|
||||||
|
result = true;
|
||||||
|
} else {
|
||||||
|
result = super.update(cmd);
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,27 @@
|
|||||||
|
package seabedexplorer.submersible.equipment.materialsampler;
|
||||||
|
|
||||||
|
import seabedexplorer.submersible.Submersible;
|
||||||
|
import seabedexplorer.submersible.equipment.Equipment;
|
||||||
|
import seabedexplorer.submersible.equipment.datacollector.DataCollector;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* MaterialSampler
|
||||||
|
*
|
||||||
|
* @author JLScott1999
|
||||||
|
*/
|
||||||
|
public abstract class MaterialSampler extends Equipment
|
||||||
|
{
|
||||||
|
double sampleVolume;
|
||||||
|
|
||||||
|
public MaterialSampler(Submersible drone, DataCollector dataCollector)
|
||||||
|
{
|
||||||
|
super(drone, dataCollector);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString()
|
||||||
|
{
|
||||||
|
return super.toString() + "Material Sampler - ";
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,39 @@
|
|||||||
|
package seabedexplorer.submersible.equipment.materialsampler;
|
||||||
|
|
||||||
|
import seabedexplorer.submersible.Submersible;
|
||||||
|
import seabedexplorer.submersible.equipment.datacollector.materialsampler.DCRockCoringDrill;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* RockCoringDrill
|
||||||
|
*
|
||||||
|
* @author JLScott1999
|
||||||
|
*/
|
||||||
|
public class RockCoringDrill extends MaterialSampler
|
||||||
|
{
|
||||||
|
|
||||||
|
public RockCoringDrill(Submersible drone, double volumeIn)
|
||||||
|
{
|
||||||
|
super(drone, new DCRockCoringDrill(volumeIn));
|
||||||
|
|
||||||
|
sampleVolume = volumeIn;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString()
|
||||||
|
{
|
||||||
|
return super.toString() + "Rock-Coring Drill";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean update(String cmd) {
|
||||||
|
boolean result;
|
||||||
|
if(cmd.equalsIgnoreCase("drill")){
|
||||||
|
this.collectData();
|
||||||
|
result = true;
|
||||||
|
} else {
|
||||||
|
result = super.update(cmd);
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,41 @@
|
|||||||
|
package seabedexplorer.submersible.equipment.topographicalmapper;
|
||||||
|
|
||||||
|
import seabedexplorer.submersible.Submersible;
|
||||||
|
import seabedexplorer.submersible.equipment.datacollector.topographicalmapper.DCLaser;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Laser
|
||||||
|
*
|
||||||
|
* @author JLScott1999
|
||||||
|
*/
|
||||||
|
public class Laser extends TopographicalMapper
|
||||||
|
{
|
||||||
|
|
||||||
|
double distance;
|
||||||
|
|
||||||
|
public Laser(Submersible drone, double distanceIn)
|
||||||
|
{
|
||||||
|
super(drone, new DCLaser(distanceIn));
|
||||||
|
|
||||||
|
distance = distanceIn;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString()
|
||||||
|
{
|
||||||
|
return super.toString() + "Laser";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean update(String cmd) {
|
||||||
|
boolean result;
|
||||||
|
if(cmd.equalsIgnoreCase("laser")){
|
||||||
|
this.collectData();
|
||||||
|
result = true;
|
||||||
|
} else {
|
||||||
|
result = super.update(cmd);
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,37 @@
|
|||||||
|
package seabedexplorer.submersible.equipment.topographicalmapper;
|
||||||
|
|
||||||
|
import seabedexplorer.submersible.Submersible;
|
||||||
|
import seabedexplorer.submersible.equipment.datacollector.topographicalmapper.DCSonar;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sonar
|
||||||
|
*
|
||||||
|
* @author JLScott1999
|
||||||
|
*/
|
||||||
|
public class Sonar extends TopographicalMapper
|
||||||
|
{
|
||||||
|
|
||||||
|
public Sonar(Submersible drone)
|
||||||
|
{
|
||||||
|
super(drone, new DCSonar());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString()
|
||||||
|
{
|
||||||
|
return super.toString() + "Sonar";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean update(String cmd) {
|
||||||
|
boolean result;
|
||||||
|
if(cmd.equalsIgnoreCase("sonar")){
|
||||||
|
this.collectData();
|
||||||
|
result = true;
|
||||||
|
} else {
|
||||||
|
result = super.update(cmd);
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,26 @@
|
|||||||
|
package seabedexplorer.submersible.equipment.topographicalmapper;
|
||||||
|
|
||||||
|
import seabedexplorer.submersible.Submersible;
|
||||||
|
import seabedexplorer.submersible.equipment.Equipment;
|
||||||
|
import seabedexplorer.submersible.equipment.datacollector.DataCollector;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* TopographicalMapper
|
||||||
|
*
|
||||||
|
* @author JLScott1999
|
||||||
|
*/
|
||||||
|
public abstract class TopographicalMapper extends Equipment
|
||||||
|
{
|
||||||
|
|
||||||
|
public TopographicalMapper(Submersible drone, DataCollector dataCollector)
|
||||||
|
{
|
||||||
|
super(drone, dataCollector);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString()
|
||||||
|
{
|
||||||
|
return super.toString() + "Topographical Mapper - ";
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,40 @@
|
|||||||
|
package seabedexplorer.submersible.equipment.waterreadings;
|
||||||
|
|
||||||
|
import seabedexplorer.submersible.Submersible;
|
||||||
|
import seabedexplorer.submersible.equipment.datacollector.waterreadings.DCIndexOfRefraction;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* IndexOfRefraction
|
||||||
|
*
|
||||||
|
* @author JLScott1999
|
||||||
|
*/
|
||||||
|
public class IndexOfRefraction extends WaterReadings
|
||||||
|
{
|
||||||
|
double angleOfIncidence;
|
||||||
|
|
||||||
|
public IndexOfRefraction(Submersible drone, double angleOfIncidenceIn)
|
||||||
|
{
|
||||||
|
super(drone, new DCIndexOfRefraction(angleOfIncidenceIn));
|
||||||
|
|
||||||
|
angleOfIncidence = angleOfIncidenceIn;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString()
|
||||||
|
{
|
||||||
|
return super.toString() + "Index Of Refraction";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean update(String cmd) {
|
||||||
|
boolean result;
|
||||||
|
if(cmd.equalsIgnoreCase("refraction")){
|
||||||
|
this.collectData();
|
||||||
|
result = true;
|
||||||
|
} else {
|
||||||
|
result = super.update(cmd);
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,37 @@
|
|||||||
|
package seabedexplorer.submersible.equipment.waterreadings;
|
||||||
|
|
||||||
|
import seabedexplorer.submersible.Submersible;
|
||||||
|
import seabedexplorer.submersible.equipment.datacollector.waterreadings.DCPH;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* PH
|
||||||
|
*
|
||||||
|
* @author JLScott1999
|
||||||
|
*/
|
||||||
|
public class PH extends WaterReadings
|
||||||
|
{
|
||||||
|
|
||||||
|
public PH(Submersible drone)
|
||||||
|
{
|
||||||
|
super(drone, new DCPH());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString()
|
||||||
|
{
|
||||||
|
return super.toString() + "pH Reader";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean update(String cmd) {
|
||||||
|
boolean result;
|
||||||
|
if(cmd.equalsIgnoreCase("ph")){
|
||||||
|
this.collectData();
|
||||||
|
result = true;
|
||||||
|
} else {
|
||||||
|
result = super.update(cmd);
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,37 @@
|
|||||||
|
package seabedexplorer.submersible.equipment.waterreadings;
|
||||||
|
|
||||||
|
import seabedexplorer.submersible.Submersible;
|
||||||
|
import seabedexplorer.submersible.equipment.datacollector.waterreadings.DCSalinity;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Salinity
|
||||||
|
*
|
||||||
|
* @author JLScott1999
|
||||||
|
*/
|
||||||
|
public class Salinity extends WaterReadings
|
||||||
|
{
|
||||||
|
|
||||||
|
public Salinity(Submersible drone)
|
||||||
|
{
|
||||||
|
super(drone, new DCSalinity());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString()
|
||||||
|
{
|
||||||
|
return super.toString() + "Salinity Reader";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean update(String cmd) {
|
||||||
|
boolean result;
|
||||||
|
if(cmd.equalsIgnoreCase("salinity")){
|
||||||
|
this.collectData();
|
||||||
|
result = true;
|
||||||
|
} else {
|
||||||
|
result = super.update(cmd);
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,26 @@
|
|||||||
|
package seabedexplorer.submersible.equipment.waterreadings;
|
||||||
|
|
||||||
|
import seabedexplorer.submersible.Submersible;
|
||||||
|
import seabedexplorer.submersible.equipment.Equipment;
|
||||||
|
import seabedexplorer.submersible.equipment.datacollector.DataCollector;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* WaterReadings
|
||||||
|
*
|
||||||
|
* @author JLScott1999
|
||||||
|
*/
|
||||||
|
public abstract class WaterReadings extends Equipment
|
||||||
|
{
|
||||||
|
|
||||||
|
public WaterReadings(Submersible drone, DataCollector dataCollector)
|
||||||
|
{
|
||||||
|
super(drone, dataCollector);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString()
|
||||||
|
{
|
||||||
|
return super.toString() + "Water Readings - ";
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
61
src/seabedexplorer/submersible/state/SubmersibleState.java
Normal file
61
src/seabedexplorer/submersible/state/SubmersibleState.java
Normal file
@ -0,0 +1,61 @@
|
|||||||
|
package seabedexplorer.submersible.state;
|
||||||
|
|
||||||
|
import seabedexplorer.submersible.Submersible;
|
||||||
|
import seabedexplorer.submersible.equipment.locationtracking.Location;
|
||||||
|
|
||||||
|
public interface SubmersibleState {
|
||||||
|
|
||||||
|
/**
|
||||||
|
*Passes the original Submersible object instance to the state, if it needs it.
|
||||||
|
* @param submersible The instance that wants to be passed.
|
||||||
|
*/
|
||||||
|
public void submersibleInstance(Submersible submersible);
|
||||||
|
|
||||||
|
//Movement methods
|
||||||
|
|
||||||
|
/**
|
||||||
|
*Moves object to a location.
|
||||||
|
* @param loc The Location of the target location.
|
||||||
|
* @return Returns if the movement command was executed successfully.
|
||||||
|
*/
|
||||||
|
public boolean move(Location loc);
|
||||||
|
|
||||||
|
/**
|
||||||
|
*Stops the movement of an object to a location.
|
||||||
|
* @return Returns if the movement stop command was executed successfully.
|
||||||
|
*/
|
||||||
|
public boolean stopMove();
|
||||||
|
|
||||||
|
/**
|
||||||
|
*Returns object back to vessel.
|
||||||
|
* @return Returns if the object was returned to the vessel successfully.
|
||||||
|
*/
|
||||||
|
public boolean returnToVessel();
|
||||||
|
|
||||||
|
/**
|
||||||
|
*Checks if the object can move.
|
||||||
|
* @return Returns if the object is able to move.
|
||||||
|
*/
|
||||||
|
public boolean canMove();
|
||||||
|
|
||||||
|
//Collection methods
|
||||||
|
|
||||||
|
/**
|
||||||
|
*Collects water sample.
|
||||||
|
* @return Returns if the water sample was collected successfully.
|
||||||
|
*/
|
||||||
|
public boolean collectWater();
|
||||||
|
|
||||||
|
/**
|
||||||
|
*Collects material sample.
|
||||||
|
* @return Returns if the material sample was collected successfully.
|
||||||
|
*/
|
||||||
|
public boolean collectMaterial();
|
||||||
|
|
||||||
|
/**
|
||||||
|
*Collects material sample.
|
||||||
|
* @return Returns if the material sample was collected successfully.
|
||||||
|
*/
|
||||||
|
public boolean collectMappingData();
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,73 @@
|
|||||||
|
package seabedexplorer.submersible.state.states;
|
||||||
|
|
||||||
|
import seabedexplorer.submersible.Submersible;
|
||||||
|
import seabedexplorer.submersible.equipment.locationtracking.Location;
|
||||||
|
import seabedexplorer.submersible.state.SubmersibleState;
|
||||||
|
import seabedexplorer.util.movement.MovementEmulation;
|
||||||
|
|
||||||
|
public class BusyActionState implements SubmersibleState
|
||||||
|
{
|
||||||
|
|
||||||
|
Submersible subContext;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean move(Location loc)
|
||||||
|
{
|
||||||
|
System.out.println("Unable to move while another action is taking place.");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean stopMove()
|
||||||
|
{
|
||||||
|
System.out.println("Unable to stop movement, movement not currently in action.");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean canMove()
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString()
|
||||||
|
{
|
||||||
|
return "Busy (Action in progress)";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void submersibleInstance(Submersible submersible)
|
||||||
|
{
|
||||||
|
subContext = submersible;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean returnToVessel()
|
||||||
|
{
|
||||||
|
System.out.println("Unable to return while an action is taking place.");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean collectWater()
|
||||||
|
{
|
||||||
|
System.out.println("Unable to collect water readings when another action is taking place.");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean collectMaterial()
|
||||||
|
{
|
||||||
|
System.out.println("Unable to collect material samples when another action is taking place.");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean collectMappingData()
|
||||||
|
{
|
||||||
|
System.out.println("Unable to collect mapping data when another action is taking place.");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,81 @@
|
|||||||
|
package seabedexplorer.submersible.state.states;
|
||||||
|
|
||||||
|
import seabedexplorer.submersible.Submersible;
|
||||||
|
import seabedexplorer.submersible.equipment.locationtracking.Location;
|
||||||
|
import seabedexplorer.submersible.state.SubmersibleState;
|
||||||
|
import seabedexplorer.util.movement.MovementEmulation;
|
||||||
|
|
||||||
|
public class BusyMoveState implements SubmersibleState
|
||||||
|
{
|
||||||
|
|
||||||
|
private Submersible subContext;
|
||||||
|
private MovementEmulation ME;
|
||||||
|
|
||||||
|
public BusyMoveState(MovementEmulation me)
|
||||||
|
{
|
||||||
|
ME = me;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean move(Location loc)
|
||||||
|
{
|
||||||
|
System.out.println("Currently moving, unable to handle another movement command.");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean stopMove()
|
||||||
|
{
|
||||||
|
ME.stopMove();
|
||||||
|
//Change state to Idle since movement has stopped.
|
||||||
|
subContext.changeState(new IdleState());
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean canMove()
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void submersibleInstance(Submersible submersible)
|
||||||
|
{
|
||||||
|
subContext = submersible;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString()
|
||||||
|
{
|
||||||
|
return "Busy (Movement in progress)";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean returnToVessel()
|
||||||
|
{
|
||||||
|
System.out.println("Unable to return to vessel while moving.");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean collectWater()
|
||||||
|
{
|
||||||
|
System.out.println("Unable to collect water sample while moving.");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean collectMaterial()
|
||||||
|
{
|
||||||
|
System.out.println("Unable to collect material sample while moving.");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean collectMappingData()
|
||||||
|
{
|
||||||
|
System.out.println("Unable to collect mapping data while moving.");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
80
src/seabedexplorer/submersible/state/states/DeployState.java
Normal file
80
src/seabedexplorer/submersible/state/states/DeployState.java
Normal file
@ -0,0 +1,80 @@
|
|||||||
|
|
||||||
|
package seabedexplorer.submersible.state.states;
|
||||||
|
|
||||||
|
import seabedexplorer.submersible.Submersible;
|
||||||
|
import seabedexplorer.submersible.equipment.locationtracking.Location;
|
||||||
|
import seabedexplorer.submersible.state.SubmersibleState;
|
||||||
|
import seabedexplorer.util.movement.MovementEmulation;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author Stedos
|
||||||
|
*/
|
||||||
|
public class DeployState implements SubmersibleState
|
||||||
|
{
|
||||||
|
|
||||||
|
private Submersible subContext;
|
||||||
|
private MovementEmulation ME;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean move(Location loc)
|
||||||
|
{
|
||||||
|
System.out.println("Unable to move while deploying.");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean stopMove()
|
||||||
|
{
|
||||||
|
System.out.println("Unable to stop moving while deploying.");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean canMove()
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString()
|
||||||
|
{
|
||||||
|
return "Deployed";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void submersibleInstance(Submersible submersible)
|
||||||
|
{
|
||||||
|
subContext = submersible;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean returnToVessel()
|
||||||
|
{
|
||||||
|
System.out.println("Unable to return while deploying.");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean collectWater()
|
||||||
|
{
|
||||||
|
System.out.println("Unable to collect water sample while deploying.");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean collectMaterial()
|
||||||
|
{
|
||||||
|
System.out.println("Unable to collect material sample while deploying.");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean collectMappingData()
|
||||||
|
{
|
||||||
|
System.out.println("Unable to collect mapping data while deploying.");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
86
src/seabedexplorer/submersible/state/states/DockedState.java
Normal file
86
src/seabedexplorer/submersible/state/states/DockedState.java
Normal file
@ -0,0 +1,86 @@
|
|||||||
|
package seabedexplorer.submersible.state.states;
|
||||||
|
|
||||||
|
import seabedexplorer.submersible.Submersible;
|
||||||
|
import seabedexplorer.submersible.equipment.locationtracking.Location;
|
||||||
|
import seabedexplorer.submersible.state.SubmersibleState;
|
||||||
|
import seabedexplorer.util.movement.MovementEmulation;
|
||||||
|
|
||||||
|
public class DockedState implements SubmersibleState
|
||||||
|
{
|
||||||
|
private Submersible subContext;
|
||||||
|
private MovementEmulation ME;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean move(Location loc)
|
||||||
|
{
|
||||||
|
subContext.changeState(new DeployState());
|
||||||
|
ME = new MovementEmulation(subContext, loc);
|
||||||
|
ME.move();
|
||||||
|
//Wait for thread to finish
|
||||||
|
try
|
||||||
|
{
|
||||||
|
ME.getThread().join();
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
System.out.println("Failed to Join Thread.");
|
||||||
|
}
|
||||||
|
//Change state to idle after movement finishes.
|
||||||
|
subContext.changeState(new IdleState());
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean stopMove()
|
||||||
|
{
|
||||||
|
System.out.println("Unable to stop moving while docked.");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean canMove()
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void submersibleInstance(Submersible submersible)
|
||||||
|
{
|
||||||
|
subContext = submersible;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString()
|
||||||
|
{
|
||||||
|
return "Docked";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean returnToVessel()
|
||||||
|
{
|
||||||
|
System.out.println("Unable to return to dock while already docked.");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean collectWater()
|
||||||
|
{
|
||||||
|
System.out.println("Unable to collect water sample while docked.");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean collectMaterial()
|
||||||
|
{
|
||||||
|
System.out.println("Unable to collect material sample while docked.");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean collectMappingData()
|
||||||
|
{
|
||||||
|
System.out.println("Unable to collect mapping data while docked.");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
134
src/seabedexplorer/submersible/state/states/IdleState.java
Normal file
134
src/seabedexplorer/submersible/state/states/IdleState.java
Normal file
@ -0,0 +1,134 @@
|
|||||||
|
package seabedexplorer.submersible.state.states;
|
||||||
|
|
||||||
|
import seabedexplorer.submersible.Submersible;
|
||||||
|
import seabedexplorer.submersible.equipment.locationtracking.Location;
|
||||||
|
import seabedexplorer.submersible.state.SubmersibleState;
|
||||||
|
import seabedexplorer.submersible.state.states.BusyActionState;
|
||||||
|
import seabedexplorer.submersible.state.states.BusyMoveState;
|
||||||
|
import seabedexplorer.submersible.state.states.DockedState;
|
||||||
|
import seabedexplorer.util.movement.MovementEmulation;
|
||||||
|
|
||||||
|
public class IdleState implements SubmersibleState
|
||||||
|
{
|
||||||
|
|
||||||
|
private Submersible subContext;
|
||||||
|
private MovementEmulation ME;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean move(Location loc)
|
||||||
|
{
|
||||||
|
ME = new MovementEmulation(subContext, loc);
|
||||||
|
subContext.changeState(new BusyMoveState(ME));
|
||||||
|
ME.move();
|
||||||
|
//Wait for thread to finish
|
||||||
|
try
|
||||||
|
{
|
||||||
|
ME.getThread().join();
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
System.out.println("Failed to Join Thread.");
|
||||||
|
}
|
||||||
|
//Change state to idle, since movement has finished
|
||||||
|
subContext.changeState(new IdleState());
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean stopMove()
|
||||||
|
{
|
||||||
|
System.out.println("Not currently moving, cannot stop the movement.");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean canMove()
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void submersibleInstance(Submersible submersible)
|
||||||
|
{
|
||||||
|
subContext = submersible;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString()
|
||||||
|
{
|
||||||
|
return "Idle";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean returnToVessel()
|
||||||
|
{
|
||||||
|
//Location of the vessel is implied 0, 0, 0, as this is where a sub starts.
|
||||||
|
ME = new MovementEmulation(subContext, new Location(0, 0, 0));
|
||||||
|
//Change context to BusyMoveState as the sub is moving
|
||||||
|
subContext.changeState(new BusyMoveState(ME));
|
||||||
|
ME.move();
|
||||||
|
//Wait for thread to finish
|
||||||
|
try
|
||||||
|
{
|
||||||
|
ME.getThread().join();
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
System.out.println("Failed to Join Thread.");
|
||||||
|
}
|
||||||
|
//Change state to Docked
|
||||||
|
subContext.changeState(new DockedState());
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean collectWater()
|
||||||
|
{
|
||||||
|
//Change state to BusyAction
|
||||||
|
subContext.changeState(new BusyActionState());
|
||||||
|
//Do data collection
|
||||||
|
subContext.update("ph");
|
||||||
|
subContext.update("refraction");
|
||||||
|
subContext.update("salinity");
|
||||||
|
//Change state to InventoryFull, since it has just used the collection.
|
||||||
|
subContext.changeState(new InventoryFullState());
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean collectMaterial()
|
||||||
|
{
|
||||||
|
//Change state to BusyAction
|
||||||
|
subContext.changeState(new BusyActionState());
|
||||||
|
//Do data collection
|
||||||
|
subContext.update("scan");
|
||||||
|
subContext.update("fluid");
|
||||||
|
subContext.update("drill");
|
||||||
|
try
|
||||||
|
{
|
||||||
|
Thread.sleep(2000);
|
||||||
|
}
|
||||||
|
catch(Exception e)
|
||||||
|
{
|
||||||
|
System.out.println("Thread failed to sleep.");
|
||||||
|
}
|
||||||
|
//Change state to InventoryFull, since it has just used the collection.
|
||||||
|
subContext.changeState(new InventoryFullState());
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean collectMappingData()
|
||||||
|
{
|
||||||
|
//Change state to BusyAction
|
||||||
|
subContext.changeState(new BusyActionState());
|
||||||
|
//Do data collection
|
||||||
|
subContext.update("laser");
|
||||||
|
subContext.update("sonar");
|
||||||
|
//Change state to Idle since this doesn't use inventory space.
|
||||||
|
subContext.changeState(new IdleState());
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,90 @@
|
|||||||
|
package seabedexplorer.submersible.state.states;
|
||||||
|
|
||||||
|
import seabedexplorer.submersible.Submersible;
|
||||||
|
import seabedexplorer.submersible.equipment.locationtracking.Location;
|
||||||
|
import seabedexplorer.submersible.state.SubmersibleState;
|
||||||
|
import seabedexplorer.util.movement.MovementEmulation;
|
||||||
|
|
||||||
|
public class InventoryFullState implements SubmersibleState
|
||||||
|
{
|
||||||
|
|
||||||
|
private Submersible subContext;
|
||||||
|
private MovementEmulation ME;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean move(Location loc)
|
||||||
|
{
|
||||||
|
System.out.println("Unable to move, inventory is full (return to the vessel to empty inventory)");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean stopMove()
|
||||||
|
{
|
||||||
|
System.out.println("Not currently moving, cannot stop the movement.");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean canMove()
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void submersibleInstance(Submersible submersible)
|
||||||
|
{
|
||||||
|
subContext = submersible;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString()
|
||||||
|
{
|
||||||
|
return "Inventory Full";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean returnToVessel()
|
||||||
|
{
|
||||||
|
//Location of the vessel is implied 0, 0, 0, as this is where a sub starts.
|
||||||
|
ME = new MovementEmulation(subContext, new Location(0, 0, 0));
|
||||||
|
//Change context to BusyMoveState as the sub is moving
|
||||||
|
subContext.changeState(new BusyMoveState(ME));
|
||||||
|
ME.move();
|
||||||
|
//Wait for thread to finish
|
||||||
|
try
|
||||||
|
{
|
||||||
|
ME.getThread().join();
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
System.out.println("Failed to Join Thread.");
|
||||||
|
}
|
||||||
|
//Change state to Docked
|
||||||
|
subContext.changeState(new DockedState());
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean collectWater()
|
||||||
|
{
|
||||||
|
System.out.println("Unable to collect water sample while inventory is full.");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean collectMaterial()
|
||||||
|
{
|
||||||
|
System.out.println("Unable to collect material sample while inventory is full.");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean collectMappingData()
|
||||||
|
{
|
||||||
|
subContext.update("laser");
|
||||||
|
subContext.update("sonar");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
36
src/seabedexplorer/util/cmd/CMDInterpreter.java
Normal file
36
src/seabedexplorer/util/cmd/CMDInterpreter.java
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
package seabedexplorer.util.cmd;
|
||||||
|
|
||||||
|
import seabedexplorer.vessel.Vessel;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* CMDInterpreter
|
||||||
|
*
|
||||||
|
* @author JLScott1999
|
||||||
|
*/
|
||||||
|
public class CMDInterpreter
|
||||||
|
{
|
||||||
|
|
||||||
|
private Vessel vessel;
|
||||||
|
|
||||||
|
public CMDInterpreter(Vessel v)
|
||||||
|
{
|
||||||
|
vessel = v;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void readCMD(String cmd)
|
||||||
|
{
|
||||||
|
if (cmd != null && cmd.length() > 0)
|
||||||
|
{
|
||||||
|
String[] cmdArray = cmd.split(" ");
|
||||||
|
switch (cmdArray[0].toLowerCase())
|
||||||
|
{
|
||||||
|
case "collectdata":
|
||||||
|
{
|
||||||
|
vessel.updateObservers(cmdArray[1]);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
9
src/seabedexplorer/util/cmd/SubmersibleCMD.java
Normal file
9
src/seabedexplorer/util/cmd/SubmersibleCMD.java
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
package seabedexplorer.util.cmd;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author Dylan Currey
|
||||||
|
*/
|
||||||
|
public enum SubmersibleCMD {
|
||||||
|
SCAN, ALL, FLUID, REFRACTION, LASER, PH, PHOTOSENSOR, DRILL, SALINITY, SONAR
|
||||||
|
}
|
36
src/seabedexplorer/util/movement/MovementEmulation.java
Normal file
36
src/seabedexplorer/util/movement/MovementEmulation.java
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
|
||||||
|
package seabedexplorer.util.movement;
|
||||||
|
|
||||||
|
import seabedexplorer.submersible.Submersible;
|
||||||
|
import seabedexplorer.submersible.equipment.locationtracking.Location;
|
||||||
|
|
||||||
|
public class MovementEmulation {
|
||||||
|
|
||||||
|
boolean isMoving;
|
||||||
|
Submersible subContext;
|
||||||
|
int speedLocal = 100;
|
||||||
|
|
||||||
|
Thread moveThread;
|
||||||
|
|
||||||
|
public MovementEmulation(Submersible sub, Location destinationLocLocal)
|
||||||
|
{
|
||||||
|
subContext = sub;
|
||||||
|
moveThread = new Thread(new ThreadMovement(sub, destinationLocLocal, speedLocal));
|
||||||
|
}
|
||||||
|
|
||||||
|
public void move()
|
||||||
|
{
|
||||||
|
moveThread.start();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void stopMove()
|
||||||
|
{
|
||||||
|
moveThread.stop();
|
||||||
|
}
|
||||||
|
|
||||||
|
public Thread getThread()
|
||||||
|
{
|
||||||
|
return moveThread;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
100
src/seabedexplorer/util/movement/ThreadMovement.java
Normal file
100
src/seabedexplorer/util/movement/ThreadMovement.java
Normal file
@ -0,0 +1,100 @@
|
|||||||
|
|
||||||
|
package seabedexplorer.util.movement;
|
||||||
|
|
||||||
|
import java.util.logging.Level;
|
||||||
|
import java.util.logging.Logger;
|
||||||
|
import seabedexplorer.submersible.Submersible;
|
||||||
|
import seabedexplorer.submersible.equipment.locationtracking.Location;
|
||||||
|
import seabedexplorer.submersible.state.states.BusyMoveState;
|
||||||
|
import seabedexplorer.submersible.state.states.IdleState;
|
||||||
|
|
||||||
|
public class ThreadMovement implements Runnable{
|
||||||
|
|
||||||
|
|
||||||
|
private Submersible subm;
|
||||||
|
private Location destinationLoc;
|
||||||
|
//In this instance, speed is the amount of milliseconds (ticks) it takes for the Submersible to move one unit (for example, 1000 ms to move one unit in the x direction)
|
||||||
|
private int speed;
|
||||||
|
|
||||||
|
public ThreadMovement(Submersible sub, Location destinationLocLocal, int speedLocal)
|
||||||
|
{
|
||||||
|
subm = sub;
|
||||||
|
destinationLoc = destinationLocLocal;
|
||||||
|
speed = speedLocal;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void run()
|
||||||
|
{
|
||||||
|
//Check if at destination location
|
||||||
|
while (!atDestinationLocation(subm.getGPS().getCurrentLocation(), destinationLoc))
|
||||||
|
{
|
||||||
|
subm.getGPS().setCurrentLocation(calculateNextCheckpointLocation(subm.getGPS().getCurrentLocation(), destinationLoc));
|
||||||
|
printLocation(subm.getGPS().getCurrentLocation());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private Location calculateNextCheckpointLocation(Location currentLocation, Location destLoc)
|
||||||
|
{
|
||||||
|
|
||||||
|
//Thread pausing to emulate movement time
|
||||||
|
try
|
||||||
|
{
|
||||||
|
Thread.sleep(speed);
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
System.out.println(e);
|
||||||
|
}
|
||||||
|
|
||||||
|
Location loc = currentLocation;
|
||||||
|
|
||||||
|
//Check X Coordinate
|
||||||
|
if (loc.getPosX() < destLoc.getPosX())
|
||||||
|
{
|
||||||
|
loc.setPosX(loc.getPosX() + 1);
|
||||||
|
}
|
||||||
|
else if (loc.getPosX() > destLoc.getPosX())
|
||||||
|
{
|
||||||
|
loc.setPosX(loc.getPosX() - 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
//Check Y Coordinate
|
||||||
|
if (loc.getPosY() < destLoc.getPosY())
|
||||||
|
{
|
||||||
|
loc.setPosY(loc.getPosY() + 1);
|
||||||
|
}
|
||||||
|
else if (loc.getPosY() > destLoc.getPosY())
|
||||||
|
{
|
||||||
|
loc.setPosY(loc.getPosY() - 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
//Check Z Coordinate
|
||||||
|
if (loc.getPosZ() < destLoc.getPosZ())
|
||||||
|
{
|
||||||
|
loc.setPosZ(loc.getPosZ() + 1);
|
||||||
|
}
|
||||||
|
else if (loc.getPosZ() > destLoc.getPosZ())
|
||||||
|
{
|
||||||
|
loc.setPosZ(loc.getPosZ() - 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
return loc;
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean atDestinationLocation(Location currentLocation, Location destLoc)
|
||||||
|
{
|
||||||
|
if ((currentLocation.getPosX() == destLoc.getPosX()) && (currentLocation.getPosY() == destLoc.getPosY()) && (currentLocation.getPosZ() == destLoc.getPosZ()))
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void printLocation(Location loc)
|
||||||
|
{
|
||||||
|
System.out.println("Location: " + loc);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
229
src/seabedexplorer/util/submersible/SubmersibleBuilder.java
Normal file
229
src/seabedexplorer/util/submersible/SubmersibleBuilder.java
Normal file
@ -0,0 +1,229 @@
|
|||||||
|
package seabedexplorer.util.submersible;
|
||||||
|
|
||||||
|
import java.security.InvalidParameterException;
|
||||||
|
import seabedexplorer.submersible.AUV;
|
||||||
|
import seabedexplorer.submersible.MS;
|
||||||
|
import seabedexplorer.submersible.ROV;
|
||||||
|
import seabedexplorer.submersible.Submersible;
|
||||||
|
import seabedexplorer.submersible.equipment.materialsampler.ChemicalScanner;
|
||||||
|
import seabedexplorer.submersible.equipment.materialsampler.HotFluidSampler;
|
||||||
|
import seabedexplorer.submersible.equipment.materialsampler.RockCoringDrill;
|
||||||
|
import seabedexplorer.submersible.equipment.topographicalmapper.Laser;
|
||||||
|
import seabedexplorer.submersible.equipment.topographicalmapper.Sonar;
|
||||||
|
import seabedexplorer.submersible.equipment.waterreadings.IndexOfRefraction;
|
||||||
|
import seabedexplorer.submersible.equipment.waterreadings.PH;
|
||||||
|
import seabedexplorer.submersible.equipment.waterreadings.Salinity;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* SubmersibleBuilder
|
||||||
|
*
|
||||||
|
* @author JLScott1999
|
||||||
|
*/
|
||||||
|
public class SubmersibleBuilder
|
||||||
|
{
|
||||||
|
|
||||||
|
private Submersible submersible;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Build a submersible easily
|
||||||
|
* @param submersibleType Type of submersible to start the creation of.
|
||||||
|
*/
|
||||||
|
public SubmersibleBuilder(SubmersibleType submersibleType)
|
||||||
|
{
|
||||||
|
System.out.println("--- Submarine Builder Start ---");
|
||||||
|
switch (submersibleType)
|
||||||
|
{
|
||||||
|
case AUTOMATED_UNDERWATER_VEHICLE:
|
||||||
|
{
|
||||||
|
System.out.println("Creating a Automated Underwater Vehicle");
|
||||||
|
submersible = new AUV();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case MANNED_SUBMERSIBLE:
|
||||||
|
{
|
||||||
|
System.out.println("Creating a Manned Submersible");
|
||||||
|
submersible = new MS();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case REMOTE_OPERATED_VEHICLE:
|
||||||
|
{
|
||||||
|
System.out.println("Creating a Remote Operated Vehicle");
|
||||||
|
submersible = new ROV();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
{
|
||||||
|
throw new InvalidParameterException("Use the SubmersibleType class to select which submersible to create");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* randomly add parts to a submersible
|
||||||
|
* @return The builder instance so it more can be added to it
|
||||||
|
*/
|
||||||
|
public SubmersibleBuilder addRandom()
|
||||||
|
{
|
||||||
|
for (int i = 0; i < (int)(Math.random() * 10 + 1); i++)
|
||||||
|
{
|
||||||
|
switch ((int)(Math.random() * 8 + 1))
|
||||||
|
{
|
||||||
|
case 1:
|
||||||
|
{
|
||||||
|
this.addLaser();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case 2:
|
||||||
|
{
|
||||||
|
this.addSonar();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case 3:
|
||||||
|
{
|
||||||
|
this.addIndexOfRefraction();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case 4:
|
||||||
|
{
|
||||||
|
this.addPH();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case 5:
|
||||||
|
{
|
||||||
|
this.addSalinity();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case 6:
|
||||||
|
{
|
||||||
|
this.addChemicalScanner();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case 7:
|
||||||
|
{
|
||||||
|
this.addHotFluidSampler();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case 8:
|
||||||
|
{
|
||||||
|
this.addRockCoringDrill();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add laser-illuminated photography to the submersible
|
||||||
|
* @return The builder instance so it more can be added to it
|
||||||
|
*/
|
||||||
|
public SubmersibleBuilder addLaser()
|
||||||
|
{
|
||||||
|
System.out.println("Adding Laser-illuminated photography");
|
||||||
|
submersible = new Laser(submersible, (double)(Math.random() * 30 + 10) / 10);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add sonar to the submersible
|
||||||
|
* @return The builder instance so it more can be added to it
|
||||||
|
*/
|
||||||
|
public SubmersibleBuilder addSonar()
|
||||||
|
{
|
||||||
|
System.out.println("Adding Sonar");
|
||||||
|
submersible = new Sonar(submersible);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add index of refraction reader to the submersible
|
||||||
|
* @return The builder instance so it more can be added to it
|
||||||
|
*/
|
||||||
|
public SubmersibleBuilder addIndexOfRefraction()
|
||||||
|
{
|
||||||
|
System.out.println("Adding Index of Refraction reader");
|
||||||
|
submersible = new IndexOfRefraction(submersible, (Math.random() * 88 + 1) + Math.random());
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add ph reader to the submersible
|
||||||
|
* @return The builder instance so it more can be added to it
|
||||||
|
*/
|
||||||
|
public SubmersibleBuilder addPH()
|
||||||
|
{
|
||||||
|
System.out.println("Adding PH reader");
|
||||||
|
submersible = new PH(submersible);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add salinity reader to the submersible
|
||||||
|
* @return The builder instance so it more can be added to it
|
||||||
|
*/
|
||||||
|
public SubmersibleBuilder addSalinity()
|
||||||
|
{
|
||||||
|
System.out.println("Adding Salinity reader");
|
||||||
|
submersible = new Salinity(submersible);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add chemical scanner to the submersible
|
||||||
|
* @return The builder instance so it more can be added to it
|
||||||
|
*/
|
||||||
|
public SubmersibleBuilder addChemicalScanner()
|
||||||
|
{
|
||||||
|
System.out.println("Adding Chemical Scanner");
|
||||||
|
submersible = new ChemicalScanner(submersible, (Math.random() * 150 + 10));
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add hot fluid sampler to the submersible
|
||||||
|
* @return The builder instance so it more can be added to it
|
||||||
|
*/
|
||||||
|
public SubmersibleBuilder addHotFluidSampler()
|
||||||
|
{
|
||||||
|
System.out.println("Adding Fluid Sampler");
|
||||||
|
submersible = new HotFluidSampler(submersible, (Math.random() * 150 + 10));
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add rock coring drill to the submersible
|
||||||
|
* @return The builder instance so it more can be added to it
|
||||||
|
*/
|
||||||
|
public SubmersibleBuilder addRockCoringDrill()
|
||||||
|
{
|
||||||
|
System.out.println("Adding RockCoring Drill");
|
||||||
|
submersible = new RockCoringDrill(submersible, (Math.random() * 150 + 10));
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Adds all equipment to the submarine
|
||||||
|
*/
|
||||||
|
public void addAll()
|
||||||
|
{
|
||||||
|
addLaser();
|
||||||
|
addSonar();
|
||||||
|
addIndexOfRefraction();
|
||||||
|
addPH();
|
||||||
|
addSalinity();
|
||||||
|
addChemicalScanner();
|
||||||
|
addHotFluidSampler();
|
||||||
|
addRockCoringDrill();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* finish the submarine build
|
||||||
|
* @return Submersible The submarine class with all the parts added to it
|
||||||
|
*/
|
||||||
|
public Submersible build()
|
||||||
|
{
|
||||||
|
System.out.println("--- Submarine Builder Finish ---");
|
||||||
|
return submersible;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
10
src/seabedexplorer/util/submersible/SubmersibleType.java
Normal file
10
src/seabedexplorer/util/submersible/SubmersibleType.java
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
package seabedexplorer.util.submersible;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author JLScott1999
|
||||||
|
*/
|
||||||
|
public enum SubmersibleType
|
||||||
|
{
|
||||||
|
AUTOMATED_UNDERWATER_VEHICLE, MANNED_SUBMERSIBLE, REMOTE_OPERATED_VEHICLE;
|
||||||
|
}
|
54
src/seabedexplorer/util/submersible/SubmersibleUtil.java
Normal file
54
src/seabedexplorer/util/submersible/SubmersibleUtil.java
Normal file
@ -0,0 +1,54 @@
|
|||||||
|
package seabedexplorer.util.submersible;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collection;
|
||||||
|
import seabedexplorer.submersible.Submersible;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* SubmersibleUtil
|
||||||
|
*
|
||||||
|
* @author JLScott1999
|
||||||
|
*/
|
||||||
|
public class SubmersibleUtil
|
||||||
|
{
|
||||||
|
|
||||||
|
private SubmersibleUtil()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* generate a up to a certain amount of submersibles.
|
||||||
|
* @param max The maximum amount of subs to create
|
||||||
|
* @return a collection of submersibles with 1 - max amount
|
||||||
|
*/
|
||||||
|
public static Collection<Submersible> GenerateRandomSubmersibles(int max)
|
||||||
|
{
|
||||||
|
Collection<Submersible> result = new ArrayList<>();
|
||||||
|
for (int i = 0; i < (int)(Math.random() * max + 1); i++)
|
||||||
|
{
|
||||||
|
SubmersibleType s = null;
|
||||||
|
switch ((int)(Math.random() * 3 + 1))
|
||||||
|
{
|
||||||
|
case 1:
|
||||||
|
{
|
||||||
|
s = SubmersibleType.AUTOMATED_UNDERWATER_VEHICLE;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case 2:
|
||||||
|
{
|
||||||
|
s = SubmersibleType.MANNED_SUBMERSIBLE;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case 3:
|
||||||
|
{
|
||||||
|
s = SubmersibleType.REMOTE_OPERATED_VEHICLE;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
result.add(new SubmersibleBuilder(s).addRandom().build());
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
58
src/seabedexplorer/vessel/Vessel.java
Normal file
58
src/seabedexplorer/vessel/Vessel.java
Normal file
@ -0,0 +1,58 @@
|
|||||||
|
package seabedexplorer.vessel;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
import seabedexplorer.observer.Observer;
|
||||||
|
import seabedexplorer.observer.Subject;
|
||||||
|
import seabedexplorer.submersible.Submersible;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class representing the vessel controlling all attached submersibles.
|
||||||
|
* Acts as subject in observer pattern
|
||||||
|
*
|
||||||
|
* @author Dylan Currey
|
||||||
|
*/
|
||||||
|
public class Vessel implements Subject
|
||||||
|
{
|
||||||
|
|
||||||
|
private List<Observer> listOfObservers = new ArrayList<>();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructor vessel class holding submersibles
|
||||||
|
*/
|
||||||
|
public Vessel()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void attach(Observer observer) {
|
||||||
|
listOfObservers.add(observer);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void detach(Observer observer) {
|
||||||
|
if(listOfObservers.contains(observer)){
|
||||||
|
listOfObservers.remove(observer);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean updateObservers(String cmd) {
|
||||||
|
boolean result = false;
|
||||||
|
for (Observer o : listOfObservers){
|
||||||
|
result = o.update(cmd);
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getNoSubmersibles() {
|
||||||
|
return listOfObservers.size();
|
||||||
|
}
|
||||||
|
|
||||||
|
public Submersible getSubmersible(int num)
|
||||||
|
{
|
||||||
|
return (Submersible) listOfObservers.get(num);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
160
test/decorator_pattern_tests/submersible/AUVTest.java
Normal file
160
test/decorator_pattern_tests/submersible/AUVTest.java
Normal file
@ -0,0 +1,160 @@
|
|||||||
|
package decorator_pattern_tests.submersible;
|
||||||
|
|
||||||
|
import static org.junit.Assert.assertEquals;
|
||||||
|
import static org.junit.Assert.assertTrue;
|
||||||
|
import org.junit.Test;
|
||||||
|
import seabedexplorer.data.Data;
|
||||||
|
import seabedexplorer.data.LaserReading;
|
||||||
|
import seabedexplorer.submersible.AUV;
|
||||||
|
import seabedexplorer.submersible.Submersible;
|
||||||
|
import seabedexplorer.submersible.equipment.locationtracking.Location;
|
||||||
|
import seabedexplorer.submersible.state.SubmersibleState;
|
||||||
|
import seabedexplorer.submersible.state.states.DeployState;
|
||||||
|
import seabedexplorer.submersible.state.states.IdleState;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* AUVTest
|
||||||
|
*
|
||||||
|
* @author JLScott1999
|
||||||
|
*/
|
||||||
|
public class AUVTest
|
||||||
|
{
|
||||||
|
|
||||||
|
public AUVTest()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test of getSubmersible method, of class AUV.
|
||||||
|
*/
|
||||||
|
@Test
|
||||||
|
public void testGetSubmersible()
|
||||||
|
{
|
||||||
|
System.out.println("getSubmersible");
|
||||||
|
Submersible instance = new AUV();
|
||||||
|
Submersible expResult = instance;
|
||||||
|
Submersible result = instance.getSubmersible();
|
||||||
|
assertEquals(expResult, result);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test of collectData method, of class AUV.
|
||||||
|
*/
|
||||||
|
@Test
|
||||||
|
public void testCollectData()
|
||||||
|
{
|
||||||
|
System.out.println("collectData");
|
||||||
|
Submersible instance = new AUV();
|
||||||
|
instance.collectData();
|
||||||
|
assertTrue(instance.getData().isEmpty());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test of addData method, of class AUV.
|
||||||
|
*/
|
||||||
|
@Test
|
||||||
|
public void testAddData()
|
||||||
|
{
|
||||||
|
System.out.println("addData");
|
||||||
|
Submersible instance = new AUV();
|
||||||
|
Data data = new LaserReading(30, 1);
|
||||||
|
instance.addData(data);
|
||||||
|
assertTrue(instance.getData().contains(data));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test of changeState method, of class AUV.
|
||||||
|
*/
|
||||||
|
@Test
|
||||||
|
public void testChangeState()
|
||||||
|
{
|
||||||
|
System.out.println("changeState");
|
||||||
|
SubmersibleState state = new IdleState();
|
||||||
|
Submersible instance = new AUV();
|
||||||
|
instance.changeState(state);
|
||||||
|
SubmersibleState result = instance.getState();
|
||||||
|
assertEquals(state, result);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test of getState method, of class AUV.
|
||||||
|
*/
|
||||||
|
@Test
|
||||||
|
public void testGetState()
|
||||||
|
{
|
||||||
|
System.out.println("getState");
|
||||||
|
Submersible instance = new AUV();
|
||||||
|
SubmersibleState expResult = new DeployState();
|
||||||
|
instance.changeState(expResult);
|
||||||
|
SubmersibleState result = instance.getState();
|
||||||
|
assertEquals(expResult, result);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test of move method, of class AUV.
|
||||||
|
*/
|
||||||
|
@Test
|
||||||
|
public void testMove()
|
||||||
|
{
|
||||||
|
System.out.println("move");
|
||||||
|
Submersible instance = new AUV();
|
||||||
|
Location expResult = new Location(1, 2, 1);
|
||||||
|
instance.move(expResult);
|
||||||
|
Location result = instance.getGPS().getCurrentLocation();
|
||||||
|
assertEquals(expResult.toString(), result.toString());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test of stopMove method, of class AUV.
|
||||||
|
*/
|
||||||
|
@Test
|
||||||
|
public void testStopMove()
|
||||||
|
{
|
||||||
|
System.out.println("stopMove");
|
||||||
|
Submersible instance = new AUV();
|
||||||
|
Location expResult = new Location();
|
||||||
|
instance.stopMove();
|
||||||
|
Location result = instance.getGPS().getCurrentLocation();
|
||||||
|
assertEquals(expResult.toString(), result.toString());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test of canMove method, of class AUV.
|
||||||
|
*/
|
||||||
|
@Test
|
||||||
|
public void testCanMove()
|
||||||
|
{
|
||||||
|
System.out.println("canMove");
|
||||||
|
Submersible instance = new AUV();
|
||||||
|
boolean expResult = true;
|
||||||
|
boolean result = instance.canMove();
|
||||||
|
assertEquals(expResult, result);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test of getSubmersibleType method, of class AUV.
|
||||||
|
*/
|
||||||
|
@Test
|
||||||
|
public void testGetSubmersibleType()
|
||||||
|
{
|
||||||
|
System.out.println("getSubmersibleType");
|
||||||
|
Submersible instance = new AUV();
|
||||||
|
String expResult = "AUV (Automated Underwater Vehicle)";
|
||||||
|
String result = instance.getSubmersibleType();
|
||||||
|
assertEquals(expResult, result);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test of toString method, of class AUV.
|
||||||
|
*/
|
||||||
|
@Test
|
||||||
|
public void testToString()
|
||||||
|
{
|
||||||
|
System.out.println("toString");
|
||||||
|
Submersible instance = new AUV();
|
||||||
|
String expResult = "Type: AUV (Automated Underwater Vehicle)\nState: Docked\nData:\nEquipment:";
|
||||||
|
String result = instance.toString();
|
||||||
|
assertEquals(expResult, result);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
160
test/decorator_pattern_tests/submersible/MSTest.java
Normal file
160
test/decorator_pattern_tests/submersible/MSTest.java
Normal file
@ -0,0 +1,160 @@
|
|||||||
|
package decorator_pattern_tests.submersible;
|
||||||
|
|
||||||
|
import static org.junit.Assert.assertEquals;
|
||||||
|
import static org.junit.Assert.assertTrue;
|
||||||
|
import org.junit.Test;
|
||||||
|
import seabedexplorer.data.Data;
|
||||||
|
import seabedexplorer.data.LaserReading;
|
||||||
|
import seabedexplorer.submersible.MS;
|
||||||
|
import seabedexplorer.submersible.Submersible;
|
||||||
|
import seabedexplorer.submersible.equipment.locationtracking.Location;
|
||||||
|
import seabedexplorer.submersible.state.SubmersibleState;
|
||||||
|
import seabedexplorer.submersible.state.states.DeployState;
|
||||||
|
import seabedexplorer.submersible.state.states.IdleState;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* MSTest
|
||||||
|
*
|
||||||
|
* @author JLScott1999
|
||||||
|
*/
|
||||||
|
public class MSTest
|
||||||
|
{
|
||||||
|
|
||||||
|
public MSTest()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test of getSubmersible method, of class MS.
|
||||||
|
*/
|
||||||
|
@Test
|
||||||
|
public void testGetSubmersible()
|
||||||
|
{
|
||||||
|
System.out.println("getSubmersible");
|
||||||
|
Submersible instance = new MS();
|
||||||
|
Submersible expResult = instance;
|
||||||
|
Submersible result = instance.getSubmersible();
|
||||||
|
assertEquals(expResult, result);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test of collectData method, of class MS.
|
||||||
|
*/
|
||||||
|
@Test
|
||||||
|
public void testCollectData()
|
||||||
|
{
|
||||||
|
System.out.println("collectData");
|
||||||
|
Submersible instance = new MS();
|
||||||
|
instance.collectData();
|
||||||
|
assertTrue(instance.getData().isEmpty());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test of addData method, of class MS.
|
||||||
|
*/
|
||||||
|
@Test
|
||||||
|
public void testAddData()
|
||||||
|
{
|
||||||
|
System.out.println("addData");
|
||||||
|
Submersible instance = new MS();
|
||||||
|
Data data = new LaserReading(30, 1);
|
||||||
|
instance.addData(data);
|
||||||
|
assertTrue(instance.getData().contains(data));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test of changeState method, of class MS.
|
||||||
|
*/
|
||||||
|
@Test
|
||||||
|
public void testChangeState()
|
||||||
|
{
|
||||||
|
System.out.println("changeState");
|
||||||
|
SubmersibleState state = new IdleState();
|
||||||
|
Submersible instance = new MS();
|
||||||
|
instance.changeState(state);
|
||||||
|
SubmersibleState result = instance.getState();
|
||||||
|
assertEquals(state, result);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test of getState method, of class MS.
|
||||||
|
*/
|
||||||
|
@Test
|
||||||
|
public void testGetState()
|
||||||
|
{
|
||||||
|
System.out.println("getState");
|
||||||
|
Submersible instance = new MS();
|
||||||
|
SubmersibleState expResult = new DeployState();
|
||||||
|
instance.changeState(expResult);
|
||||||
|
SubmersibleState result = instance.getState();
|
||||||
|
assertEquals(expResult, result);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test of move method, of class MS.
|
||||||
|
*/
|
||||||
|
@Test
|
||||||
|
public void testMove()
|
||||||
|
{
|
||||||
|
System.out.println("move");
|
||||||
|
Submersible instance = new MS();
|
||||||
|
Location expResult = new Location(1, 2, 1);
|
||||||
|
instance.move(expResult);
|
||||||
|
Location result = instance.getGPS().getCurrentLocation();
|
||||||
|
assertEquals(expResult.toString(), result.toString());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test of stopMove method, of class MS.
|
||||||
|
*/
|
||||||
|
@Test
|
||||||
|
public void testStopMove()
|
||||||
|
{
|
||||||
|
System.out.println("stopMove");
|
||||||
|
Submersible instance = new MS();
|
||||||
|
Location expResult = new Location();
|
||||||
|
instance.stopMove();
|
||||||
|
Location result = instance.getGPS().getCurrentLocation();
|
||||||
|
assertEquals(expResult.toString(), result.toString());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test of canMove method, of class MS.
|
||||||
|
*/
|
||||||
|
@Test
|
||||||
|
public void testCanMove()
|
||||||
|
{
|
||||||
|
System.out.println("canMove");
|
||||||
|
Submersible instance = new MS();
|
||||||
|
boolean expResult = true;
|
||||||
|
boolean result = instance.canMove();
|
||||||
|
assertEquals(expResult, result);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test of getSubmersibleType method, of class MS.
|
||||||
|
*/
|
||||||
|
@Test
|
||||||
|
public void testGetSubmersibleType()
|
||||||
|
{
|
||||||
|
System.out.println("getSubmersibleType");
|
||||||
|
Submersible instance = new MS();
|
||||||
|
String expResult = "MS (Manned Submersible)";
|
||||||
|
String result = instance.getSubmersibleType();
|
||||||
|
assertEquals(expResult, result);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test of toString method, of class MS.
|
||||||
|
*/
|
||||||
|
@Test
|
||||||
|
public void testToString()
|
||||||
|
{
|
||||||
|
System.out.println("toString");
|
||||||
|
Submersible instance = new MS();
|
||||||
|
String expResult = "Type: MS (Manned Submersible)\nState: Docked\nData:\nEquipment:";
|
||||||
|
String result = instance.toString();
|
||||||
|
assertEquals(expResult, result);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
160
test/decorator_pattern_tests/submersible/ROVTest.java
Normal file
160
test/decorator_pattern_tests/submersible/ROVTest.java
Normal file
@ -0,0 +1,160 @@
|
|||||||
|
package decorator_pattern_tests.submersible;
|
||||||
|
|
||||||
|
import static org.junit.Assert.assertEquals;
|
||||||
|
import static org.junit.Assert.assertTrue;
|
||||||
|
import org.junit.Test;
|
||||||
|
import seabedexplorer.data.Data;
|
||||||
|
import seabedexplorer.data.LaserReading;
|
||||||
|
import seabedexplorer.submersible.ROV;
|
||||||
|
import seabedexplorer.submersible.Submersible;
|
||||||
|
import seabedexplorer.submersible.equipment.locationtracking.Location;
|
||||||
|
import seabedexplorer.submersible.state.SubmersibleState;
|
||||||
|
import seabedexplorer.submersible.state.states.DeployState;
|
||||||
|
import seabedexplorer.submersible.state.states.IdleState;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ROVTest
|
||||||
|
*
|
||||||
|
* @author JLScott1999
|
||||||
|
*/
|
||||||
|
public class ROVTest
|
||||||
|
{
|
||||||
|
|
||||||
|
public ROVTest()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test of getSubmersible method, of class ROV.
|
||||||
|
*/
|
||||||
|
@Test
|
||||||
|
public void testGetSubmersible()
|
||||||
|
{
|
||||||
|
System.out.println("getSubmersible");
|
||||||
|
Submersible instance = new ROV();
|
||||||
|
Submersible expResult = instance;
|
||||||
|
Submersible result = instance.getSubmersible();
|
||||||
|
assertEquals(expResult, result);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test of collectData method, of class ROV.
|
||||||
|
*/
|
||||||
|
@Test
|
||||||
|
public void testCollectData()
|
||||||
|
{
|
||||||
|
System.out.println("collectData");
|
||||||
|
Submersible instance = new ROV();
|
||||||
|
instance.collectData();
|
||||||
|
assertTrue(instance.getData().isEmpty());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test of addData method, of class ROV.
|
||||||
|
*/
|
||||||
|
@Test
|
||||||
|
public void testAddData()
|
||||||
|
{
|
||||||
|
System.out.println("addData");
|
||||||
|
Submersible instance = new ROV();
|
||||||
|
Data data = new LaserReading(30, 1);
|
||||||
|
instance.addData(data);
|
||||||
|
assertTrue(instance.getData().contains(data));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test of changeState method, of class ROV.
|
||||||
|
*/
|
||||||
|
@Test
|
||||||
|
public void testChangeState()
|
||||||
|
{
|
||||||
|
System.out.println("changeState");
|
||||||
|
SubmersibleState state = new IdleState();
|
||||||
|
Submersible instance = new ROV();
|
||||||
|
instance.changeState(state);
|
||||||
|
SubmersibleState result = instance.getState();
|
||||||
|
assertEquals(state, result);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test of getState method, of class ROV.
|
||||||
|
*/
|
||||||
|
@Test
|
||||||
|
public void testGetState()
|
||||||
|
{
|
||||||
|
System.out.println("getState");
|
||||||
|
Submersible instance = new ROV();
|
||||||
|
SubmersibleState expResult = new DeployState();
|
||||||
|
instance.changeState(expResult);
|
||||||
|
SubmersibleState result = instance.getState();
|
||||||
|
assertEquals(expResult, result);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test of move method, of class ROV.
|
||||||
|
*/
|
||||||
|
@Test
|
||||||
|
public void testMove()
|
||||||
|
{
|
||||||
|
System.out.println("move");
|
||||||
|
Submersible instance = new ROV();
|
||||||
|
Location expResult = new Location(1, 2, 1);
|
||||||
|
instance.move(expResult);
|
||||||
|
Location result = instance.getGPS().getCurrentLocation();
|
||||||
|
assertEquals(expResult.toString(), result.toString());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test of stopMove method, of class ROV.
|
||||||
|
*/
|
||||||
|
@Test
|
||||||
|
public void testStopMove()
|
||||||
|
{
|
||||||
|
System.out.println("stopMove");
|
||||||
|
Submersible instance = new ROV();
|
||||||
|
Location expResult = new Location();
|
||||||
|
instance.stopMove();
|
||||||
|
Location result = instance.getGPS().getCurrentLocation();
|
||||||
|
assertEquals(expResult.toString(), result.toString());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test of canMove method, of class ROV.
|
||||||
|
*/
|
||||||
|
@Test
|
||||||
|
public void testCanMove()
|
||||||
|
{
|
||||||
|
System.out.println("canMove");
|
||||||
|
Submersible instance = new ROV();
|
||||||
|
boolean expResult = true;
|
||||||
|
boolean result = instance.canMove();
|
||||||
|
assertEquals(expResult, result);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test of getSubmersibleType method, of class ROV.
|
||||||
|
*/
|
||||||
|
@Test
|
||||||
|
public void testGetSubmersibleType()
|
||||||
|
{
|
||||||
|
System.out.println("getSubmersibleType");
|
||||||
|
Submersible instance = new ROV();
|
||||||
|
String expResult = "ROV (Remote Operated Vehicle)";
|
||||||
|
String result = instance.getSubmersibleType();
|
||||||
|
assertEquals(expResult, result);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test of toString method, of class ROV.
|
||||||
|
*/
|
||||||
|
@Test
|
||||||
|
public void testToString()
|
||||||
|
{
|
||||||
|
System.out.println("toString");
|
||||||
|
Submersible instance = new ROV();
|
||||||
|
String expResult = "Type: ROV (Remote Operated Vehicle)\nState: Docked\nData:\nEquipment:";
|
||||||
|
String result = instance.toString();
|
||||||
|
assertEquals(expResult, result);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,161 @@
|
|||||||
|
package decorator_pattern_tests.submersible.equipment;
|
||||||
|
|
||||||
|
import static org.junit.Assert.assertEquals;
|
||||||
|
import static org.junit.Assert.assertTrue;
|
||||||
|
import org.junit.Test;
|
||||||
|
import seabedexplorer.data.Data;
|
||||||
|
import seabedexplorer.data.LaserReading;
|
||||||
|
import seabedexplorer.submersible.AUV;
|
||||||
|
import seabedexplorer.submersible.Submersible;
|
||||||
|
import seabedexplorer.submersible.equipment.PhotoSensor;
|
||||||
|
import seabedexplorer.submersible.equipment.locationtracking.Location;
|
||||||
|
import seabedexplorer.submersible.state.SubmersibleState;
|
||||||
|
import seabedexplorer.submersible.state.states.DeployState;
|
||||||
|
import seabedexplorer.submersible.state.states.IdleState;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* PhotoSensor
|
||||||
|
*
|
||||||
|
* @author JLScott1999
|
||||||
|
*/
|
||||||
|
public class PhotoSensorTest
|
||||||
|
{
|
||||||
|
|
||||||
|
public PhotoSensorTest()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test of getSubmersible method, of class PhotoSensor.
|
||||||
|
*/
|
||||||
|
@Test
|
||||||
|
public void testGetSubmersible()
|
||||||
|
{
|
||||||
|
System.out.println("getSubmersible");
|
||||||
|
Submersible expResult = new AUV();
|
||||||
|
Submersible instance = new PhotoSensor(expResult);
|
||||||
|
Submersible result = instance.getSubmersible();
|
||||||
|
assertEquals(expResult, result);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test of collectData method, of class PhotoSensor.
|
||||||
|
*/
|
||||||
|
@Test
|
||||||
|
public void testCollectData()
|
||||||
|
{
|
||||||
|
System.out.println("collectData");
|
||||||
|
Submersible instance = new PhotoSensor(new AUV());
|
||||||
|
instance.collectData();
|
||||||
|
assertTrue(instance.getData().size() > 0 && instance.getData().size() < 2);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test of addData method, of class PhotoSensor.
|
||||||
|
*/
|
||||||
|
@Test
|
||||||
|
public void testAddData()
|
||||||
|
{
|
||||||
|
System.out.println("addData");
|
||||||
|
Submersible instance = new PhotoSensor(new AUV());
|
||||||
|
Data data = new LaserReading(30, 1);
|
||||||
|
instance.addData(data);
|
||||||
|
assertTrue(instance.getData().contains(data));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test of changeState method, of class PhotoSensor.
|
||||||
|
*/
|
||||||
|
@Test
|
||||||
|
public void testChangeState()
|
||||||
|
{
|
||||||
|
System.out.println("changeState");
|
||||||
|
SubmersibleState state = new IdleState();
|
||||||
|
Submersible instance = new PhotoSensor(new AUV());
|
||||||
|
instance.changeState(state);
|
||||||
|
SubmersibleState result = instance.getState();
|
||||||
|
assertEquals(state, result);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test of getState method, of class PhotoSensor.
|
||||||
|
*/
|
||||||
|
@Test
|
||||||
|
public void testGetState()
|
||||||
|
{
|
||||||
|
System.out.println("getState");
|
||||||
|
Submersible instance = new PhotoSensor(new AUV());
|
||||||
|
SubmersibleState expResult = new DeployState();
|
||||||
|
instance.changeState(expResult);
|
||||||
|
SubmersibleState result = instance.getState();
|
||||||
|
assertEquals(expResult, result);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test of move method, of class PhotoSensor.
|
||||||
|
*/
|
||||||
|
@Test
|
||||||
|
public void testMove()
|
||||||
|
{
|
||||||
|
System.out.println("move");
|
||||||
|
Submersible instance = new PhotoSensor(new AUV());
|
||||||
|
Location expResult = new Location(1, 2, 1);
|
||||||
|
instance.move(expResult);
|
||||||
|
Location result = instance.getGPS().getCurrentLocation();
|
||||||
|
assertEquals(expResult.toString(), result.toString());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test of stopMove method, of class PhotoSensor.
|
||||||
|
*/
|
||||||
|
@Test
|
||||||
|
public void testStopMove()
|
||||||
|
{
|
||||||
|
System.out.println("stopMove");
|
||||||
|
Submersible instance = new PhotoSensor(new AUV());
|
||||||
|
Location expResult = new Location();
|
||||||
|
instance.stopMove();
|
||||||
|
Location result = instance.getGPS().getCurrentLocation();
|
||||||
|
assertEquals(expResult.toString(), result.toString());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test of canMove method, of class PhotoSensor.
|
||||||
|
*/
|
||||||
|
@Test
|
||||||
|
public void testCanMove()
|
||||||
|
{
|
||||||
|
System.out.println("canMove");
|
||||||
|
Submersible instance = new PhotoSensor(new AUV());
|
||||||
|
boolean expResult = true;
|
||||||
|
boolean result = instance.canMove();
|
||||||
|
assertEquals(expResult, result);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test of getSubmersibleType method, of class PhotoSensor.
|
||||||
|
*/
|
||||||
|
@Test
|
||||||
|
public void testGetSubmersibleType()
|
||||||
|
{
|
||||||
|
System.out.println("getSubmersibleType");
|
||||||
|
Submersible instance = new PhotoSensor(new AUV());
|
||||||
|
String expResult = "AUV (Automated Underwater Vehicle)";
|
||||||
|
String result = instance.getSubmersibleType();
|
||||||
|
assertEquals(expResult, result);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test of toString method, of class PhotoSensor.
|
||||||
|
*/
|
||||||
|
@Test
|
||||||
|
public void testToString()
|
||||||
|
{
|
||||||
|
System.out.println("toString");
|
||||||
|
Submersible instance = new PhotoSensor(new AUV());
|
||||||
|
String expResult = "Type: AUV (Automated Underwater Vehicle)\nState: Docked\nData:\nEquipment:\n Photo Sensor";
|
||||||
|
String result = instance.toString();
|
||||||
|
assertEquals(expResult, result);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,160 @@
|
|||||||
|
package decorator_pattern_tests.submersible.equipment.materialsampler;
|
||||||
|
|
||||||
|
import static org.junit.Assert.*;
|
||||||
|
import org.junit.Test;
|
||||||
|
import seabedexplorer.data.Data;
|
||||||
|
import seabedexplorer.data.LaserReading;
|
||||||
|
import seabedexplorer.submersible.AUV;
|
||||||
|
import seabedexplorer.submersible.Submersible;
|
||||||
|
import seabedexplorer.submersible.equipment.locationtracking.Location;
|
||||||
|
import seabedexplorer.submersible.equipment.materialsampler.ChemicalScanner;
|
||||||
|
import seabedexplorer.submersible.state.SubmersibleState;
|
||||||
|
import seabedexplorer.submersible.state.states.DeployState;
|
||||||
|
import seabedexplorer.submersible.state.states.IdleState;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ChemicalScannerTest
|
||||||
|
*
|
||||||
|
* @author JLScott1999
|
||||||
|
*/
|
||||||
|
public class ChemicalScannerTest
|
||||||
|
{
|
||||||
|
|
||||||
|
public ChemicalScannerTest()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test of getSubmersible method, of class ChemicalScanner.
|
||||||
|
*/
|
||||||
|
@Test
|
||||||
|
public void testGetSubmersible()
|
||||||
|
{
|
||||||
|
System.out.println("getSubmersible");
|
||||||
|
Submersible expResult = new AUV();
|
||||||
|
Submersible instance = new ChemicalScanner(expResult, 100);
|
||||||
|
Submersible result = instance.getSubmersible();
|
||||||
|
assertEquals(expResult, result);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test of collectData method, of class ChemicalScanner.
|
||||||
|
*/
|
||||||
|
@Test
|
||||||
|
public void testCollectData()
|
||||||
|
{
|
||||||
|
System.out.println("collectData");
|
||||||
|
Submersible instance = new ChemicalScanner(new AUV(), 100);
|
||||||
|
instance.collectData();
|
||||||
|
assertTrue(instance.getData().size() > 0 && instance.getData().size() < 2);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test of addData method, of class ChemicalScanner.
|
||||||
|
*/
|
||||||
|
@Test
|
||||||
|
public void testAddData()
|
||||||
|
{
|
||||||
|
System.out.println("addData");
|
||||||
|
Submersible instance = new ChemicalScanner(new AUV(), 100);
|
||||||
|
Data data = new LaserReading(30, 1);
|
||||||
|
instance.addData(data);
|
||||||
|
assertTrue(instance.getData().contains(data));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test of changeState method, of class ChemicalScanner.
|
||||||
|
*/
|
||||||
|
@Test
|
||||||
|
public void testChangeState()
|
||||||
|
{
|
||||||
|
System.out.println("changeState");
|
||||||
|
SubmersibleState state = new IdleState();
|
||||||
|
Submersible instance = new ChemicalScanner(new AUV(), 100);
|
||||||
|
instance.changeState(state);
|
||||||
|
SubmersibleState result = instance.getState();
|
||||||
|
assertEquals(state, result);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test of getState method, of class ChemicalScanner.
|
||||||
|
*/
|
||||||
|
@Test
|
||||||
|
public void testGetState()
|
||||||
|
{
|
||||||
|
System.out.println("getState");
|
||||||
|
Submersible instance = new ChemicalScanner(new AUV(), 100);
|
||||||
|
SubmersibleState expResult = new DeployState();
|
||||||
|
instance.changeState(expResult);
|
||||||
|
SubmersibleState result = instance.getState();
|
||||||
|
assertEquals(expResult, result);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test of move method, of class ChemicalScanner.
|
||||||
|
*/
|
||||||
|
@Test
|
||||||
|
public void testMove()
|
||||||
|
{
|
||||||
|
System.out.println("move");
|
||||||
|
Submersible instance = new ChemicalScanner(new AUV(), 100);
|
||||||
|
Location expResult = new Location(1, 2, 1);
|
||||||
|
instance.move(expResult);
|
||||||
|
Location result = instance.getGPS().getCurrentLocation();
|
||||||
|
assertEquals(expResult.toString(), result.toString());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test of stopMove method, of class ChemicalScanner.
|
||||||
|
*/
|
||||||
|
@Test
|
||||||
|
public void testStopMove()
|
||||||
|
{
|
||||||
|
System.out.println("stopMove");
|
||||||
|
Submersible instance = new ChemicalScanner(new AUV(), 100);
|
||||||
|
Location expResult = new Location();
|
||||||
|
instance.stopMove();
|
||||||
|
Location result = instance.getGPS().getCurrentLocation();
|
||||||
|
assertEquals(expResult.toString(), result.toString());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test of canMove method, of class ChemicalScanner.
|
||||||
|
*/
|
||||||
|
@Test
|
||||||
|
public void testCanMove()
|
||||||
|
{
|
||||||
|
System.out.println("canMove");
|
||||||
|
Submersible instance = new ChemicalScanner(new AUV(), 100);
|
||||||
|
boolean expResult = true;
|
||||||
|
boolean result = instance.canMove();
|
||||||
|
assertEquals(expResult, result);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test of getSubmersibleType method, of class ChemicalScanner.
|
||||||
|
*/
|
||||||
|
@Test
|
||||||
|
public void testGetSubmersibleType()
|
||||||
|
{
|
||||||
|
System.out.println("getSubmersibleType");
|
||||||
|
Submersible instance = new ChemicalScanner(new AUV(), 100);
|
||||||
|
String expResult = "AUV (Automated Underwater Vehicle)";
|
||||||
|
String result = instance.getSubmersibleType();
|
||||||
|
assertEquals(expResult, result);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test of toString method, of class ChemicalScanner.
|
||||||
|
*/
|
||||||
|
@Test
|
||||||
|
public void testToString()
|
||||||
|
{
|
||||||
|
System.out.println("toString");
|
||||||
|
Submersible instance = new ChemicalScanner(new AUV(), 100);
|
||||||
|
String expResult = "Type: AUV (Automated Underwater Vehicle)\nState: Docked\nData:\nEquipment:\n Material Sampler - Chemical Scanner";
|
||||||
|
String result = instance.toString();
|
||||||
|
assertEquals(expResult, result);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,160 @@
|
|||||||
|
package decorator_pattern_tests.submersible.equipment.materialsampler;
|
||||||
|
|
||||||
|
import static org.junit.Assert.*;
|
||||||
|
import org.junit.Test;
|
||||||
|
import seabedexplorer.data.Data;
|
||||||
|
import seabedexplorer.data.LaserReading;
|
||||||
|
import seabedexplorer.submersible.AUV;
|
||||||
|
import seabedexplorer.submersible.Submersible;
|
||||||
|
import seabedexplorer.submersible.equipment.locationtracking.Location;
|
||||||
|
import seabedexplorer.submersible.equipment.materialsampler.HotFluidSampler;
|
||||||
|
import seabedexplorer.submersible.state.SubmersibleState;
|
||||||
|
import seabedexplorer.submersible.state.states.DeployState;
|
||||||
|
import seabedexplorer.submersible.state.states.IdleState;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* HotFluidSamplerTest
|
||||||
|
*
|
||||||
|
* @author JLScott1999
|
||||||
|
*/
|
||||||
|
public class HotFluidSamplerTest
|
||||||
|
{
|
||||||
|
|
||||||
|
public HotFluidSamplerTest()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test of getSubmersible method, of class HotFluidSampler.
|
||||||
|
*/
|
||||||
|
@Test
|
||||||
|
public void testGetSubmersible()
|
||||||
|
{
|
||||||
|
System.out.println("getSubmersible");
|
||||||
|
Submersible expResult = new AUV();
|
||||||
|
Submersible instance = new HotFluidSampler(expResult, 100);
|
||||||
|
Submersible result = instance.getSubmersible();
|
||||||
|
assertEquals(expResult, result);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test of collectData method, of class HotFluidSampler.
|
||||||
|
*/
|
||||||
|
@Test
|
||||||
|
public void testCollectData()
|
||||||
|
{
|
||||||
|
System.out.println("collectData");
|
||||||
|
Submersible instance = new HotFluidSampler(new AUV(), 100);
|
||||||
|
instance.collectData();
|
||||||
|
assertTrue(instance.getData().size() > 0 && instance.getData().size() < 2);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test of addData method, of class HotFluidSampler.
|
||||||
|
*/
|
||||||
|
@Test
|
||||||
|
public void testAddData()
|
||||||
|
{
|
||||||
|
System.out.println("addData");
|
||||||
|
Submersible instance = new HotFluidSampler(new AUV(), 100);
|
||||||
|
Data data = new LaserReading(30, 1);
|
||||||
|
instance.addData(data);
|
||||||
|
assertTrue(instance.getData().contains(data));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test of changeState method, of class HotFluidSampler.
|
||||||
|
*/
|
||||||
|
@Test
|
||||||
|
public void testChangeState()
|
||||||
|
{
|
||||||
|
System.out.println("changeState");
|
||||||
|
SubmersibleState state = new IdleState();
|
||||||
|
Submersible instance = new HotFluidSampler(new AUV(), 100);
|
||||||
|
instance.changeState(state);
|
||||||
|
SubmersibleState result = instance.getState();
|
||||||
|
assertEquals(state, result);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test of getState method, of class HotFluidSampler.
|
||||||
|
*/
|
||||||
|
@Test
|
||||||
|
public void testGetState()
|
||||||
|
{
|
||||||
|
System.out.println("getState");
|
||||||
|
Submersible instance = new HotFluidSampler(new AUV(), 100);
|
||||||
|
SubmersibleState expResult = new DeployState();
|
||||||
|
instance.changeState(expResult);
|
||||||
|
SubmersibleState result = instance.getState();
|
||||||
|
assertEquals(expResult, result);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test of move method, of class HotFluidSampler.
|
||||||
|
*/
|
||||||
|
@Test
|
||||||
|
public void testMove()
|
||||||
|
{
|
||||||
|
System.out.println("move");
|
||||||
|
Submersible instance = new HotFluidSampler(new AUV(), 100);
|
||||||
|
Location expResult = new Location(1, 2, 1);
|
||||||
|
instance.move(expResult);
|
||||||
|
Location result = instance.getGPS().getCurrentLocation();
|
||||||
|
assertEquals(expResult.toString(), result.toString());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test of stopMove method, of class HotFluidSampler.
|
||||||
|
*/
|
||||||
|
@Test
|
||||||
|
public void testStopMove()
|
||||||
|
{
|
||||||
|
System.out.println("stopMove");
|
||||||
|
Submersible instance = new HotFluidSampler(new AUV(), 100);
|
||||||
|
Location expResult = new Location();
|
||||||
|
instance.stopMove();
|
||||||
|
Location result = instance.getGPS().getCurrentLocation();
|
||||||
|
assertEquals(expResult.toString(), result.toString());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test of canMove method, of class HotFluidSampler.
|
||||||
|
*/
|
||||||
|
@Test
|
||||||
|
public void testCanMove()
|
||||||
|
{
|
||||||
|
System.out.println("canMove");
|
||||||
|
Submersible instance = new HotFluidSampler(new AUV(), 100);
|
||||||
|
boolean expResult = true;
|
||||||
|
boolean result = instance.canMove();
|
||||||
|
assertEquals(expResult, result);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test of getSubmersibleType method, of class HotFluidSampler.
|
||||||
|
*/
|
||||||
|
@Test
|
||||||
|
public void testGetSubmersibleType()
|
||||||
|
{
|
||||||
|
System.out.println("getSubmersibleType");
|
||||||
|
Submersible instance = new HotFluidSampler(new AUV(), 100);
|
||||||
|
String expResult = "AUV (Automated Underwater Vehicle)";
|
||||||
|
String result = instance.getSubmersibleType();
|
||||||
|
assertEquals(expResult, result);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test of toString method, of class HotFluidSampler.
|
||||||
|
*/
|
||||||
|
@Test
|
||||||
|
public void testToString()
|
||||||
|
{
|
||||||
|
System.out.println("toString");
|
||||||
|
Submersible instance = new HotFluidSampler(new AUV(), 100);
|
||||||
|
String expResult = "Type: AUV (Automated Underwater Vehicle)\nState: Docked\nData:\nEquipment:\n Material Sampler - Hot Fluid Sampler";
|
||||||
|
String result = instance.toString();
|
||||||
|
assertEquals(expResult, result);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,160 @@
|
|||||||
|
package decorator_pattern_tests.submersible.equipment.materialsampler;
|
||||||
|
|
||||||
|
import static org.junit.Assert.*;
|
||||||
|
import org.junit.Test;
|
||||||
|
import seabedexplorer.data.Data;
|
||||||
|
import seabedexplorer.data.LaserReading;
|
||||||
|
import seabedexplorer.submersible.AUV;
|
||||||
|
import seabedexplorer.submersible.Submersible;
|
||||||
|
import seabedexplorer.submersible.equipment.locationtracking.Location;
|
||||||
|
import seabedexplorer.submersible.equipment.materialsampler.RockCoringDrill;
|
||||||
|
import seabedexplorer.submersible.state.SubmersibleState;
|
||||||
|
import seabedexplorer.submersible.state.states.DeployState;
|
||||||
|
import seabedexplorer.submersible.state.states.IdleState;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* RockCoringDrillTest
|
||||||
|
*
|
||||||
|
* @author JLScott1999
|
||||||
|
*/
|
||||||
|
public class RockCoringDrillTest
|
||||||
|
{
|
||||||
|
|
||||||
|
public RockCoringDrillTest()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test of getSubmersible method, of class RockCoringDrill.
|
||||||
|
*/
|
||||||
|
@Test
|
||||||
|
public void testGetSubmersible()
|
||||||
|
{
|
||||||
|
System.out.println("getSubmersible");
|
||||||
|
Submersible expResult = new AUV();
|
||||||
|
Submersible instance = new RockCoringDrill(expResult, 100);
|
||||||
|
Submersible result = instance.getSubmersible();
|
||||||
|
assertEquals(expResult, result);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test of collectData method, of class RockCoringDrill.
|
||||||
|
*/
|
||||||
|
@Test
|
||||||
|
public void testCollectData()
|
||||||
|
{
|
||||||
|
System.out.println("collectData");
|
||||||
|
Submersible instance = new RockCoringDrill(new AUV(), 100);
|
||||||
|
instance.collectData();
|
||||||
|
assertTrue(instance.getData().size() > 0 && instance.getData().size() < 2);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test of addData method, of class RockCoringDrill.
|
||||||
|
*/
|
||||||
|
@Test
|
||||||
|
public void testAddData()
|
||||||
|
{
|
||||||
|
System.out.println("addData");
|
||||||
|
Submersible instance = new RockCoringDrill(new AUV(), 100);
|
||||||
|
Data data = new LaserReading(30, 1);
|
||||||
|
instance.addData(data);
|
||||||
|
assertTrue(instance.getData().contains(data));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test of changeState method, of class RockCoringDrill.
|
||||||
|
*/
|
||||||
|
@Test
|
||||||
|
public void testChangeState()
|
||||||
|
{
|
||||||
|
System.out.println("changeState");
|
||||||
|
SubmersibleState state = new IdleState();
|
||||||
|
Submersible instance = new RockCoringDrill(new AUV(), 100);
|
||||||
|
instance.changeState(state);
|
||||||
|
SubmersibleState result = instance.getState();
|
||||||
|
assertEquals(state, result);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test of getState method, of class RockCoringDrill.
|
||||||
|
*/
|
||||||
|
@Test
|
||||||
|
public void testGetState()
|
||||||
|
{
|
||||||
|
System.out.println("getState");
|
||||||
|
Submersible instance = new RockCoringDrill(new AUV(), 100);
|
||||||
|
SubmersibleState expResult = new DeployState();
|
||||||
|
instance.changeState(expResult);
|
||||||
|
SubmersibleState result = instance.getState();
|
||||||
|
assertEquals(expResult, result);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test of move method, of class RockCoringDrill.
|
||||||
|
*/
|
||||||
|
@Test
|
||||||
|
public void testMove()
|
||||||
|
{
|
||||||
|
System.out.println("move");
|
||||||
|
Submersible instance = new RockCoringDrill(new AUV(), 100);
|
||||||
|
Location expResult = new Location(1, 2, 1);
|
||||||
|
instance.move(expResult);
|
||||||
|
Location result = instance.getGPS().getCurrentLocation();
|
||||||
|
assertEquals(expResult.toString(), result.toString());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test of stopMove method, of class RockCoringDrill.
|
||||||
|
*/
|
||||||
|
@Test
|
||||||
|
public void testStopMove()
|
||||||
|
{
|
||||||
|
System.out.println("stopMove");
|
||||||
|
Submersible instance = new RockCoringDrill(new AUV(), 100);
|
||||||
|
Location expResult = new Location();
|
||||||
|
instance.stopMove();
|
||||||
|
Location result = instance.getGPS().getCurrentLocation();
|
||||||
|
assertEquals(expResult.toString(), result.toString());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test of canMove method, of class RockCoringDrill.
|
||||||
|
*/
|
||||||
|
@Test
|
||||||
|
public void testCanMove()
|
||||||
|
{
|
||||||
|
System.out.println("canMove");
|
||||||
|
Submersible instance = new RockCoringDrill(new AUV(), 100);
|
||||||
|
boolean expResult = true;
|
||||||
|
boolean result = instance.canMove();
|
||||||
|
assertEquals(expResult, result);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test of getSubmersibleType method, of class RockCoringDrill.
|
||||||
|
*/
|
||||||
|
@Test
|
||||||
|
public void testGetSubmersibleType()
|
||||||
|
{
|
||||||
|
System.out.println("getSubmersibleType");
|
||||||
|
Submersible instance = new RockCoringDrill(new AUV(), 100);
|
||||||
|
String expResult = "AUV (Automated Underwater Vehicle)";
|
||||||
|
String result = instance.getSubmersibleType();
|
||||||
|
assertEquals(expResult, result);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test of toString method, of class RockCoringDrill.
|
||||||
|
*/
|
||||||
|
@Test
|
||||||
|
public void testToString()
|
||||||
|
{
|
||||||
|
System.out.println("toString");
|
||||||
|
Submersible instance = new RockCoringDrill(new AUV(), 100);
|
||||||
|
String expResult = "Type: AUV (Automated Underwater Vehicle)\nState: Docked\nData:\nEquipment:\n Material Sampler - Rock-Coring Drill";
|
||||||
|
String result = instance.toString();
|
||||||
|
assertEquals(expResult, result);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,160 @@
|
|||||||
|
package decorator_pattern_tests.submersible.equipment.topographicalmapper;
|
||||||
|
|
||||||
|
import static org.junit.Assert.*;
|
||||||
|
import org.junit.Test;
|
||||||
|
import seabedexplorer.data.Data;
|
||||||
|
import seabedexplorer.data.LaserReading;
|
||||||
|
import seabedexplorer.submersible.AUV;
|
||||||
|
import seabedexplorer.submersible.Submersible;
|
||||||
|
import seabedexplorer.submersible.equipment.locationtracking.Location;
|
||||||
|
import seabedexplorer.submersible.equipment.topographicalmapper.Laser;
|
||||||
|
import seabedexplorer.submersible.state.SubmersibleState;
|
||||||
|
import seabedexplorer.submersible.state.states.DeployState;
|
||||||
|
import seabedexplorer.submersible.state.states.IdleState;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* LaserTest
|
||||||
|
*
|
||||||
|
* @author JLScott1999
|
||||||
|
*/
|
||||||
|
public class LaserTest
|
||||||
|
{
|
||||||
|
|
||||||
|
public LaserTest()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test of getSubmersible method, of class Laser.
|
||||||
|
*/
|
||||||
|
@Test
|
||||||
|
public void testGetSubmersible()
|
||||||
|
{
|
||||||
|
System.out.println("getSubmersible");
|
||||||
|
Submersible expResult = new AUV();
|
||||||
|
Submersible instance = new Laser(expResult, 0.3);
|
||||||
|
Submersible result = instance.getSubmersible();
|
||||||
|
assertEquals(expResult, result);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test of collectData method, of class Laser.
|
||||||
|
*/
|
||||||
|
@Test
|
||||||
|
public void testCollectData()
|
||||||
|
{
|
||||||
|
System.out.println("collectData");
|
||||||
|
Submersible instance = new Laser(new AUV(), 0.3);
|
||||||
|
instance.collectData();
|
||||||
|
assertTrue(instance.getData().size() > 0 && instance.getData().size() < 2);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test of addData method, of class Laser.
|
||||||
|
*/
|
||||||
|
@Test
|
||||||
|
public void testAddData()
|
||||||
|
{
|
||||||
|
System.out.println("addData");
|
||||||
|
Submersible instance = new Laser(new AUV(), 0.3);
|
||||||
|
Data data = new LaserReading(30, 1);
|
||||||
|
instance.addData(data);
|
||||||
|
assertTrue(instance.getData().contains(data));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test of changeState method, of class Laser.
|
||||||
|
*/
|
||||||
|
@Test
|
||||||
|
public void testChangeState()
|
||||||
|
{
|
||||||
|
System.out.println("changeState");
|
||||||
|
SubmersibleState state = new IdleState();
|
||||||
|
Submersible instance = new Laser(new AUV(), 0.3);
|
||||||
|
instance.changeState(state);
|
||||||
|
SubmersibleState result = instance.getState();
|
||||||
|
assertEquals(state, result);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test of getState method, of class Laser.
|
||||||
|
*/
|
||||||
|
@Test
|
||||||
|
public void testGetState()
|
||||||
|
{
|
||||||
|
System.out.println("getState");
|
||||||
|
Submersible instance = new Laser(new AUV(), 0.3);
|
||||||
|
SubmersibleState expResult = new DeployState();
|
||||||
|
instance.changeState(expResult);
|
||||||
|
SubmersibleState result = instance.getState();
|
||||||
|
assertEquals(expResult, result);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test of move method, of class Laser.
|
||||||
|
*/
|
||||||
|
@Test
|
||||||
|
public void testMove()
|
||||||
|
{
|
||||||
|
System.out.println("move");
|
||||||
|
Submersible instance = new Laser(new AUV(), 0.3);
|
||||||
|
Location expResult = new Location(1, 2, 1);
|
||||||
|
instance.move(expResult);
|
||||||
|
Location result = instance.getGPS().getCurrentLocation();
|
||||||
|
assertEquals(expResult.toString(), result.toString());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test of stopMove method, of class Laser.
|
||||||
|
*/
|
||||||
|
@Test
|
||||||
|
public void testStopMove()
|
||||||
|
{
|
||||||
|
System.out.println("stopMove");
|
||||||
|
Submersible instance = new Laser(new AUV(), 0.3);
|
||||||
|
Location expResult = new Location();
|
||||||
|
instance.stopMove();
|
||||||
|
Location result = instance.getGPS().getCurrentLocation();
|
||||||
|
assertEquals(expResult.toString(), result.toString());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test of canMove method, of class Laser.
|
||||||
|
*/
|
||||||
|
@Test
|
||||||
|
public void testCanMove()
|
||||||
|
{
|
||||||
|
System.out.println("canMove");
|
||||||
|
Submersible instance = new Laser(new AUV(), 0.3);
|
||||||
|
boolean expResult = true;
|
||||||
|
boolean result = instance.canMove();
|
||||||
|
assertEquals(expResult, result);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test of getSubmersibleType method, of class Laser.
|
||||||
|
*/
|
||||||
|
@Test
|
||||||
|
public void testGetSubmersibleType()
|
||||||
|
{
|
||||||
|
System.out.println("getSubmersibleType");
|
||||||
|
Submersible instance = new Laser(new AUV(), 0.3);
|
||||||
|
String expResult = "AUV (Automated Underwater Vehicle)";
|
||||||
|
String result = instance.getSubmersibleType();
|
||||||
|
assertEquals(expResult, result);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test of toString method, of class Laser.
|
||||||
|
*/
|
||||||
|
@Test
|
||||||
|
public void testToString()
|
||||||
|
{
|
||||||
|
System.out.println("toString");
|
||||||
|
Submersible instance = new Laser(new AUV(), 0.3);
|
||||||
|
String expResult = "Type: AUV (Automated Underwater Vehicle)\nState: Docked\nData:\nEquipment:\n Topographical Mapper - Laser";
|
||||||
|
String result = instance.toString();
|
||||||
|
assertEquals(expResult, result);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,160 @@
|
|||||||
|
package decorator_pattern_tests.submersible.equipment.topographicalmapper;
|
||||||
|
|
||||||
|
import static org.junit.Assert.*;
|
||||||
|
import org.junit.Test;
|
||||||
|
import seabedexplorer.data.Data;
|
||||||
|
import seabedexplorer.data.LaserReading;
|
||||||
|
import seabedexplorer.submersible.AUV;
|
||||||
|
import seabedexplorer.submersible.Submersible;
|
||||||
|
import seabedexplorer.submersible.equipment.locationtracking.Location;
|
||||||
|
import seabedexplorer.submersible.equipment.topographicalmapper.Sonar;
|
||||||
|
import seabedexplorer.submersible.state.SubmersibleState;
|
||||||
|
import seabedexplorer.submersible.state.states.DeployState;
|
||||||
|
import seabedexplorer.submersible.state.states.IdleState;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* SonarTest
|
||||||
|
*
|
||||||
|
* @author JLScott1999
|
||||||
|
*/
|
||||||
|
public class SonarTest
|
||||||
|
{
|
||||||
|
|
||||||
|
public SonarTest()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test of getSubmersible method, of class Sonar.
|
||||||
|
*/
|
||||||
|
@Test
|
||||||
|
public void testGetSubmersible()
|
||||||
|
{
|
||||||
|
System.out.println("getSubmersible");
|
||||||
|
Submersible expResult = new AUV();
|
||||||
|
Submersible instance = new Sonar(expResult);
|
||||||
|
Submersible result = instance.getSubmersible();
|
||||||
|
assertEquals(expResult, result);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test of collectData method, of class Sonar.
|
||||||
|
*/
|
||||||
|
@Test
|
||||||
|
public void testCollectData()
|
||||||
|
{
|
||||||
|
System.out.println("collectData");
|
||||||
|
Submersible instance = new Sonar(new AUV());
|
||||||
|
instance.collectData();
|
||||||
|
assertTrue(instance.getData().size() > 0 && instance.getData().size() < 2);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test of addData method, of class Sonar.
|
||||||
|
*/
|
||||||
|
@Test
|
||||||
|
public void testAddData()
|
||||||
|
{
|
||||||
|
System.out.println("addData");
|
||||||
|
Submersible instance = new Sonar(new AUV());
|
||||||
|
Data data = new LaserReading(30, 1);
|
||||||
|
instance.addData(data);
|
||||||
|
assertTrue(instance.getData().contains(data));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test of changeState method, of class Sonar.
|
||||||
|
*/
|
||||||
|
@Test
|
||||||
|
public void testChangeState()
|
||||||
|
{
|
||||||
|
System.out.println("changeState");
|
||||||
|
SubmersibleState state = new IdleState();
|
||||||
|
Submersible instance = new Sonar(new AUV());
|
||||||
|
instance.changeState(state);
|
||||||
|
SubmersibleState result = instance.getState();
|
||||||
|
assertEquals(state, result);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test of getState method, of class Sonar.
|
||||||
|
*/
|
||||||
|
@Test
|
||||||
|
public void testGetState()
|
||||||
|
{
|
||||||
|
System.out.println("getState");
|
||||||
|
Submersible instance = new Sonar(new AUV());
|
||||||
|
SubmersibleState expResult = new DeployState();
|
||||||
|
instance.changeState(expResult);
|
||||||
|
SubmersibleState result = instance.getState();
|
||||||
|
assertEquals(expResult, result);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test of move method, of class Sonar.
|
||||||
|
*/
|
||||||
|
@Test
|
||||||
|
public void testMove()
|
||||||
|
{
|
||||||
|
System.out.println("move");
|
||||||
|
Submersible instance = new Sonar(new AUV());
|
||||||
|
Location expResult = new Location(1, 2, 1);
|
||||||
|
instance.move(expResult);
|
||||||
|
Location result = instance.getGPS().getCurrentLocation();
|
||||||
|
assertEquals(expResult.toString(), result.toString());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test of stopMove method, of class Sonar.
|
||||||
|
*/
|
||||||
|
@Test
|
||||||
|
public void testStopMove()
|
||||||
|
{
|
||||||
|
System.out.println("stopMove");
|
||||||
|
Submersible instance = new Sonar(new AUV());
|
||||||
|
Location expResult = new Location();
|
||||||
|
instance.stopMove();
|
||||||
|
Location result = instance.getGPS().getCurrentLocation();
|
||||||
|
assertEquals(expResult.toString(), result.toString());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test of canMove method, of class Sonar.
|
||||||
|
*/
|
||||||
|
@Test
|
||||||
|
public void testCanMove()
|
||||||
|
{
|
||||||
|
System.out.println("canMove");
|
||||||
|
Submersible instance = new Sonar(new AUV());
|
||||||
|
boolean expResult = true;
|
||||||
|
boolean result = instance.canMove();
|
||||||
|
assertEquals(expResult, result);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test of getSubmersibleType method, of class Sonar.
|
||||||
|
*/
|
||||||
|
@Test
|
||||||
|
public void testGetSubmersibleType()
|
||||||
|
{
|
||||||
|
System.out.println("getSubmersibleType");
|
||||||
|
Submersible instance = new Sonar(new AUV());
|
||||||
|
String expResult = "AUV (Automated Underwater Vehicle)";
|
||||||
|
String result = instance.getSubmersibleType();
|
||||||
|
assertEquals(expResult, result);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test of toString method, of class Sonar.
|
||||||
|
*/
|
||||||
|
@Test
|
||||||
|
public void testToString()
|
||||||
|
{
|
||||||
|
System.out.println("toString");
|
||||||
|
Submersible instance = new Sonar(new AUV());
|
||||||
|
String expResult = "Type: AUV (Automated Underwater Vehicle)\nState: Docked\nData:\nEquipment:\n Topographical Mapper - Sonar";
|
||||||
|
String result = instance.toString();
|
||||||
|
assertEquals(expResult, result);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,159 @@
|
|||||||
|
package decorator_pattern_tests.submersible.equipment.waterreadings;
|
||||||
|
|
||||||
|
import static org.junit.Assert.*;
|
||||||
|
import org.junit.Test;
|
||||||
|
import seabedexplorer.data.Data;
|
||||||
|
import seabedexplorer.data.LaserReading;
|
||||||
|
import seabedexplorer.submersible.AUV;
|
||||||
|
import seabedexplorer.submersible.Submersible;
|
||||||
|
import seabedexplorer.submersible.equipment.locationtracking.Location;
|
||||||
|
import seabedexplorer.submersible.equipment.waterreadings.IndexOfRefraction;
|
||||||
|
import seabedexplorer.submersible.state.SubmersibleState;
|
||||||
|
import seabedexplorer.submersible.state.states.DeployState;
|
||||||
|
import seabedexplorer.submersible.state.states.IdleState;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author JLScott1999
|
||||||
|
*/
|
||||||
|
public class IndexOfRefractionTest
|
||||||
|
{
|
||||||
|
|
||||||
|
public IndexOfRefractionTest()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test of getSubmersible method, of class IndexOfRefraction.
|
||||||
|
*/
|
||||||
|
@Test
|
||||||
|
public void testGetSubmersible()
|
||||||
|
{
|
||||||
|
System.out.println("getSubmersible");
|
||||||
|
Submersible expResult = new AUV();
|
||||||
|
Submersible instance = new IndexOfRefraction(expResult, 30);
|
||||||
|
Submersible result = instance.getSubmersible();
|
||||||
|
assertEquals(expResult, result);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test of collectData method, of class IndexOfRefraction.
|
||||||
|
*/
|
||||||
|
@Test
|
||||||
|
public void testCollectData()
|
||||||
|
{
|
||||||
|
System.out.println("collectData");
|
||||||
|
Submersible instance = new IndexOfRefraction(new AUV(), 30);
|
||||||
|
instance.collectData();
|
||||||
|
assertTrue(instance.getData().size() > 0 && instance.getData().size() < 2);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test of addData method, of class IndexOfRefraction.
|
||||||
|
*/
|
||||||
|
@Test
|
||||||
|
public void testAddData()
|
||||||
|
{
|
||||||
|
System.out.println("addData");
|
||||||
|
Submersible instance = new IndexOfRefraction(new AUV(), 30);
|
||||||
|
Data data = new LaserReading(30, 1);
|
||||||
|
instance.addData(data);
|
||||||
|
assertTrue(instance.getData().contains(data));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test of changeState method, of class IndexOfRefraction.
|
||||||
|
*/
|
||||||
|
@Test
|
||||||
|
public void testChangeState()
|
||||||
|
{
|
||||||
|
System.out.println("changeState");
|
||||||
|
SubmersibleState state = new IdleState();
|
||||||
|
Submersible instance = new IndexOfRefraction(new AUV(), 30);
|
||||||
|
instance.changeState(state);
|
||||||
|
SubmersibleState result = instance.getState();
|
||||||
|
assertEquals(state, result);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test of getState method, of class IndexOfRefraction.
|
||||||
|
*/
|
||||||
|
@Test
|
||||||
|
public void testGetState()
|
||||||
|
{
|
||||||
|
System.out.println("getState");
|
||||||
|
Submersible instance = new IndexOfRefraction(new AUV(), 30);
|
||||||
|
SubmersibleState expResult = new DeployState();
|
||||||
|
instance.changeState(expResult);
|
||||||
|
SubmersibleState result = instance.getState();
|
||||||
|
assertEquals(expResult, result);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test of move method, of class IndexOfRefraction.
|
||||||
|
*/
|
||||||
|
@Test
|
||||||
|
public void testMove()
|
||||||
|
{
|
||||||
|
System.out.println("move");
|
||||||
|
Submersible instance = new IndexOfRefraction(new AUV(), 30);
|
||||||
|
Location expResult = new Location(1, 2, 1);
|
||||||
|
instance.move(expResult);
|
||||||
|
Location result = instance.getGPS().getCurrentLocation();
|
||||||
|
assertEquals(expResult.toString(), result.toString());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test of stopMove method, of class IndexOfRefraction.
|
||||||
|
*/
|
||||||
|
@Test
|
||||||
|
public void testStopMove()
|
||||||
|
{
|
||||||
|
System.out.println("stopMove");
|
||||||
|
Submersible instance = new IndexOfRefraction(new AUV(), 30);
|
||||||
|
Location expResult = new Location();
|
||||||
|
instance.stopMove();
|
||||||
|
Location result = instance.getGPS().getCurrentLocation();
|
||||||
|
assertEquals(expResult.toString(), result.toString());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test of canMove method, of class IndexOfRefraction.
|
||||||
|
*/
|
||||||
|
@Test
|
||||||
|
public void testCanMove()
|
||||||
|
{
|
||||||
|
System.out.println("canMove");
|
||||||
|
Submersible instance = new IndexOfRefraction(new AUV(), 30);
|
||||||
|
boolean expResult = true;
|
||||||
|
boolean result = instance.canMove();
|
||||||
|
assertEquals(expResult, result);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test of getSubmersibleType method, of class IndexOfRefraction.
|
||||||
|
*/
|
||||||
|
@Test
|
||||||
|
public void testGetSubmersibleType()
|
||||||
|
{
|
||||||
|
System.out.println("getSubmersibleType");
|
||||||
|
Submersible instance = new IndexOfRefraction(new AUV(), 30);
|
||||||
|
String expResult = "AUV (Automated Underwater Vehicle)";
|
||||||
|
String result = instance.getSubmersibleType();
|
||||||
|
assertEquals(expResult, result);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test of toString method, of class IndexOfRefraction.
|
||||||
|
*/
|
||||||
|
@Test
|
||||||
|
public void testToString()
|
||||||
|
{
|
||||||
|
System.out.println("toString");
|
||||||
|
Submersible instance = new IndexOfRefraction(new AUV(), 30);
|
||||||
|
String expResult = "Type: AUV (Automated Underwater Vehicle)\nState: Docked\nData:\nEquipment:\n Water Readings - Index Of Refraction";
|
||||||
|
String result = instance.toString();
|
||||||
|
assertEquals(expResult, result);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,160 @@
|
|||||||
|
package decorator_pattern_tests.submersible.equipment.waterreadings;
|
||||||
|
|
||||||
|
import static org.junit.Assert.*;
|
||||||
|
import org.junit.Test;
|
||||||
|
import seabedexplorer.data.Data;
|
||||||
|
import seabedexplorer.data.LaserReading;
|
||||||
|
import seabedexplorer.submersible.AUV;
|
||||||
|
import seabedexplorer.submersible.Submersible;
|
||||||
|
import seabedexplorer.submersible.equipment.locationtracking.Location;
|
||||||
|
import seabedexplorer.submersible.equipment.waterreadings.PH;
|
||||||
|
import seabedexplorer.submersible.state.SubmersibleState;
|
||||||
|
import seabedexplorer.submersible.state.states.DeployState;
|
||||||
|
import seabedexplorer.submersible.state.states.IdleState;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* PHTest
|
||||||
|
*
|
||||||
|
* @author JLScott1999
|
||||||
|
*/
|
||||||
|
public class PHTest
|
||||||
|
{
|
||||||
|
|
||||||
|
public PHTest()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test of getSubmersible method, of class PH.
|
||||||
|
*/
|
||||||
|
@Test
|
||||||
|
public void testGetSubmersible()
|
||||||
|
{
|
||||||
|
System.out.println("getSubmersible");
|
||||||
|
Submersible expResult = new AUV();
|
||||||
|
Submersible instance = new PH(expResult);
|
||||||
|
Submersible result = instance.getSubmersible();
|
||||||
|
assertEquals(expResult, result);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test of collectData method, of class PH.
|
||||||
|
*/
|
||||||
|
@Test
|
||||||
|
public void testCollectData()
|
||||||
|
{
|
||||||
|
System.out.println("collectData");
|
||||||
|
Submersible instance = new PH(new AUV());
|
||||||
|
instance.collectData();
|
||||||
|
assertTrue(instance.getData().size() > 0 && instance.getData().size() < 2);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test of addData method, of class PH.
|
||||||
|
*/
|
||||||
|
@Test
|
||||||
|
public void testAddData()
|
||||||
|
{
|
||||||
|
System.out.println("addData");
|
||||||
|
Submersible instance = new PH(new AUV());
|
||||||
|
Data data = new LaserReading(30, 1);
|
||||||
|
instance.addData(data);
|
||||||
|
assertTrue(instance.getData().contains(data));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test of changeState method, of class PH.
|
||||||
|
*/
|
||||||
|
@Test
|
||||||
|
public void testChangeState()
|
||||||
|
{
|
||||||
|
System.out.println("changeState");
|
||||||
|
SubmersibleState state = new IdleState();
|
||||||
|
Submersible instance = new PH(new AUV());
|
||||||
|
instance.changeState(state);
|
||||||
|
SubmersibleState result = instance.getState();
|
||||||
|
assertEquals(state, result);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test of getState method, of class PH.
|
||||||
|
*/
|
||||||
|
@Test
|
||||||
|
public void testGetState()
|
||||||
|
{
|
||||||
|
System.out.println("getState");
|
||||||
|
Submersible instance = new PH(new AUV());
|
||||||
|
SubmersibleState expResult = new DeployState();
|
||||||
|
instance.changeState(expResult);
|
||||||
|
SubmersibleState result = instance.getState();
|
||||||
|
assertEquals(expResult, result);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test of move method, of class PH.
|
||||||
|
*/
|
||||||
|
@Test
|
||||||
|
public void testMove()
|
||||||
|
{
|
||||||
|
System.out.println("move");
|
||||||
|
Submersible instance = new PH(new AUV());
|
||||||
|
Location expResult = new Location(1, 2, 1);
|
||||||
|
instance.move(expResult);
|
||||||
|
Location result = instance.getGPS().getCurrentLocation();
|
||||||
|
assertEquals(expResult.toString(), result.toString());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test of stopMove method, of class PH.
|
||||||
|
*/
|
||||||
|
@Test
|
||||||
|
public void testStopMove()
|
||||||
|
{
|
||||||
|
System.out.println("stopMove");
|
||||||
|
Submersible instance = new PH(new AUV());
|
||||||
|
Location expResult = new Location();
|
||||||
|
instance.stopMove();
|
||||||
|
Location result = instance.getGPS().getCurrentLocation();
|
||||||
|
assertEquals(expResult.toString(), result.toString());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test of canMove method, of class PH.
|
||||||
|
*/
|
||||||
|
@Test
|
||||||
|
public void testCanMove()
|
||||||
|
{
|
||||||
|
System.out.println("canMove");
|
||||||
|
Submersible instance = new PH(new AUV());
|
||||||
|
boolean expResult = true;
|
||||||
|
boolean result = instance.canMove();
|
||||||
|
assertEquals(expResult, result);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test of getSubmersibleType method, of class PH.
|
||||||
|
*/
|
||||||
|
@Test
|
||||||
|
public void testGetSubmersibleType()
|
||||||
|
{
|
||||||
|
System.out.println("getSubmersibleType");
|
||||||
|
Submersible instance = new PH(new AUV());
|
||||||
|
String expResult = "AUV (Automated Underwater Vehicle)";
|
||||||
|
String result = instance.getSubmersibleType();
|
||||||
|
assertEquals(expResult, result);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test of toString method, of class PH.
|
||||||
|
*/
|
||||||
|
@Test
|
||||||
|
public void testToString()
|
||||||
|
{
|
||||||
|
System.out.println("toString");
|
||||||
|
Submersible instance = new PH(new AUV());
|
||||||
|
String expResult = "Type: AUV (Automated Underwater Vehicle)\nState: Docked\nData:\nEquipment:\n Water Readings - pH Reader";
|
||||||
|
String result = instance.toString();
|
||||||
|
assertEquals(expResult, result);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,161 @@
|
|||||||
|
package decorator_pattern_tests.submersible.equipment.waterreadings;
|
||||||
|
|
||||||
|
import static org.junit.Assert.assertEquals;
|
||||||
|
import static org.junit.Assert.assertTrue;
|
||||||
|
import org.junit.Test;
|
||||||
|
import seabedexplorer.data.Data;
|
||||||
|
import seabedexplorer.data.LaserReading;
|
||||||
|
import seabedexplorer.submersible.AUV;
|
||||||
|
import seabedexplorer.submersible.Submersible;
|
||||||
|
import seabedexplorer.submersible.equipment.locationtracking.Location;
|
||||||
|
import seabedexplorer.submersible.equipment.waterreadings.Salinity;
|
||||||
|
import seabedexplorer.submersible.state.SubmersibleState;
|
||||||
|
import seabedexplorer.submersible.state.states.DeployState;
|
||||||
|
import seabedexplorer.submersible.state.states.IdleState;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* SalinityTest
|
||||||
|
*
|
||||||
|
* @author JLScott1999
|
||||||
|
*/
|
||||||
|
public class SalinityTest
|
||||||
|
{
|
||||||
|
|
||||||
|
public SalinityTest()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test of getSubmersible method, of class Salinity.
|
||||||
|
*/
|
||||||
|
@Test
|
||||||
|
public void testGetSubmersible()
|
||||||
|
{
|
||||||
|
System.out.println("getSubmersible");
|
||||||
|
Submersible expResult = new AUV();
|
||||||
|
Submersible instance = new Salinity(expResult);
|
||||||
|
Submersible result = instance.getSubmersible();
|
||||||
|
assertEquals(expResult, result);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test of collectData method, of class Salinity.
|
||||||
|
*/
|
||||||
|
@Test
|
||||||
|
public void testCollectData()
|
||||||
|
{
|
||||||
|
System.out.println("collectData");
|
||||||
|
Submersible instance = new Salinity(new AUV());
|
||||||
|
instance.collectData();
|
||||||
|
assertTrue(instance.getData().size() > 0 && instance.getData().size() < 2);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test of addData method, of class Salinity.
|
||||||
|
*/
|
||||||
|
@Test
|
||||||
|
public void testAddData()
|
||||||
|
{
|
||||||
|
System.out.println("addData");
|
||||||
|
Submersible instance = new Salinity(new AUV());
|
||||||
|
Data data = new LaserReading(30, 1);
|
||||||
|
instance.addData(data);
|
||||||
|
assertTrue(instance.getData().contains(data));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test of changeState method, of class Salinity.
|
||||||
|
*/
|
||||||
|
@Test
|
||||||
|
public void testChangeState()
|
||||||
|
{
|
||||||
|
System.out.println("changeState");
|
||||||
|
SubmersibleState state = new IdleState();
|
||||||
|
Submersible instance = new Salinity(new AUV());
|
||||||
|
instance.changeState(state);
|
||||||
|
SubmersibleState result = instance.getState();
|
||||||
|
assertEquals(state, result);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test of getState method, of class Salinity.
|
||||||
|
*/
|
||||||
|
@Test
|
||||||
|
public void testGetState()
|
||||||
|
{
|
||||||
|
System.out.println("getState");
|
||||||
|
Submersible instance = new Salinity(new AUV());
|
||||||
|
SubmersibleState expResult = new DeployState();
|
||||||
|
instance.changeState(expResult);
|
||||||
|
SubmersibleState result = instance.getState();
|
||||||
|
assertEquals(expResult, result);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test of move method, of class Salinity.
|
||||||
|
*/
|
||||||
|
@Test
|
||||||
|
public void testMove()
|
||||||
|
{
|
||||||
|
System.out.println("move");
|
||||||
|
Submersible instance = new Salinity(new AUV());
|
||||||
|
Location expResult = new Location(1, 2, 1);
|
||||||
|
instance.move(expResult);
|
||||||
|
Location result = instance.getGPS().getCurrentLocation();
|
||||||
|
assertEquals(expResult.toString(), result.toString());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test of stopMove method, of class Salinity.
|
||||||
|
*/
|
||||||
|
@Test
|
||||||
|
public void testStopMove()
|
||||||
|
{
|
||||||
|
System.out.println("stopMove");
|
||||||
|
Submersible instance = new Salinity(new AUV());
|
||||||
|
Location expResult = new Location();
|
||||||
|
instance.stopMove();
|
||||||
|
Location result = instance.getGPS().getCurrentLocation();
|
||||||
|
assertEquals(expResult.toString(), result.toString());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test of canMove method, of class Salinity.
|
||||||
|
*/
|
||||||
|
@Test
|
||||||
|
public void testCanMove()
|
||||||
|
{
|
||||||
|
System.out.println("canMove");
|
||||||
|
Submersible instance = new Salinity(new AUV());
|
||||||
|
boolean expResult = true;
|
||||||
|
boolean result = instance.canMove();
|
||||||
|
assertEquals(expResult, result);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test of getSubmersibleType method, of class Salinity.
|
||||||
|
*/
|
||||||
|
@Test
|
||||||
|
public void testGetSubmersibleType()
|
||||||
|
{
|
||||||
|
System.out.println("getSubmersibleType");
|
||||||
|
Submersible instance = new Salinity(new AUV());
|
||||||
|
String expResult = "AUV (Automated Underwater Vehicle)";
|
||||||
|
String result = instance.getSubmersibleType();
|
||||||
|
assertEquals(expResult, result);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test of toString method, of class Salinity.
|
||||||
|
*/
|
||||||
|
@Test
|
||||||
|
public void testToString()
|
||||||
|
{
|
||||||
|
System.out.println("toString");
|
||||||
|
Submersible instance = new Salinity(new AUV());
|
||||||
|
String expResult = "Type: AUV (Automated Underwater Vehicle)\nState: Docked\nData:\nEquipment:\n Water Readings - Salinity Reader";
|
||||||
|
String result = instance.toString();
|
||||||
|
assertEquals(expResult, result);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,33 @@
|
|||||||
|
package observer_pattern_tests.submersible.equipment;
|
||||||
|
|
||||||
|
import static org.hamcrest.CoreMatchers.equalTo;
|
||||||
|
import static org.hamcrest.CoreMatchers.is;
|
||||||
|
import static org.hamcrest.CoreMatchers.not;
|
||||||
|
import org.junit.Test;
|
||||||
|
import static org.junit.Assert.*;
|
||||||
|
import seabedexplorer.submersible.ROV;
|
||||||
|
import seabedexplorer.submersible.equipment.PhotoSensor;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author Dylan Currey
|
||||||
|
*/
|
||||||
|
public class PhotoSensorTest {
|
||||||
|
|
||||||
|
public PhotoSensorTest() {
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test of update method, of class PhotoSensor.
|
||||||
|
*/
|
||||||
|
@Test
|
||||||
|
public void testUpdate() {
|
||||||
|
System.out.println("update");
|
||||||
|
PhotoSensor s = new PhotoSensor(new ROV());
|
||||||
|
String before = s.toString();
|
||||||
|
s.update("photosensor");
|
||||||
|
String after = s.toString();
|
||||||
|
assertThat(after, is(not(equalTo(before))));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,33 @@
|
|||||||
|
package observer_pattern_tests.submersible.equipment.materialsampler;
|
||||||
|
|
||||||
|
import static org.hamcrest.CoreMatchers.equalTo;
|
||||||
|
import static org.hamcrest.CoreMatchers.is;
|
||||||
|
import static org.hamcrest.CoreMatchers.not;
|
||||||
|
import org.junit.Test;
|
||||||
|
import static org.junit.Assert.*;
|
||||||
|
import seabedexplorer.submersible.ROV;
|
||||||
|
import seabedexplorer.submersible.equipment.materialsampler.ChemicalScanner;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author Dylan Currey
|
||||||
|
*/
|
||||||
|
public class ChemicalScannerTest {
|
||||||
|
|
||||||
|
public ChemicalScannerTest() {
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test of update method, of class ChemicalScanner.
|
||||||
|
*/
|
||||||
|
@Test
|
||||||
|
public void testUpdate() {
|
||||||
|
System.out.println("update");
|
||||||
|
ChemicalScanner s = new ChemicalScanner(new ROV(), 1);
|
||||||
|
String before = s.toString();
|
||||||
|
s.update("scan");
|
||||||
|
String after = s.toString();
|
||||||
|
assertThat(after, is(not(equalTo(before))));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,33 @@
|
|||||||
|
package observer_pattern_tests.submersible.equipment.materialsampler;
|
||||||
|
|
||||||
|
import static org.hamcrest.CoreMatchers.equalTo;
|
||||||
|
import static org.hamcrest.CoreMatchers.is;
|
||||||
|
import static org.hamcrest.CoreMatchers.not;
|
||||||
|
import org.junit.Test;
|
||||||
|
import static org.junit.Assert.*;
|
||||||
|
import seabedexplorer.submersible.ROV;
|
||||||
|
import seabedexplorer.submersible.equipment.materialsampler.HotFluidSampler;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author Dylan Currey
|
||||||
|
*/
|
||||||
|
public class HotFluidSamplerTest {
|
||||||
|
|
||||||
|
public HotFluidSamplerTest() {
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test of update method, of class HotFluidSampler.
|
||||||
|
*/
|
||||||
|
@Test
|
||||||
|
public void testUpdate() {
|
||||||
|
System.out.println("update");
|
||||||
|
HotFluidSampler s = new HotFluidSampler(new ROV(),1);
|
||||||
|
String before = s.toString();
|
||||||
|
s.update("fluid");
|
||||||
|
String after = s.toString();
|
||||||
|
assertThat(after, is(not(equalTo(before))));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,33 @@
|
|||||||
|
package observer_pattern_tests.submersible.equipment.materialsampler;
|
||||||
|
|
||||||
|
import static org.hamcrest.CoreMatchers.equalTo;
|
||||||
|
import static org.hamcrest.CoreMatchers.is;
|
||||||
|
import static org.hamcrest.CoreMatchers.not;
|
||||||
|
import org.junit.Test;
|
||||||
|
import static org.junit.Assert.*;
|
||||||
|
import seabedexplorer.submersible.ROV;
|
||||||
|
import seabedexplorer.submersible.equipment.materialsampler.RockCoringDrill;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author Dylan Currey
|
||||||
|
*/
|
||||||
|
public class RockCoringDrillTest {
|
||||||
|
|
||||||
|
public RockCoringDrillTest() {
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test of update method, of class RockCoringDrill.
|
||||||
|
*/
|
||||||
|
@Test
|
||||||
|
public void testUpdate() {
|
||||||
|
System.out.println("update");
|
||||||
|
RockCoringDrill s = new RockCoringDrill(new ROV(),1);
|
||||||
|
String before = s.toString();
|
||||||
|
s.update("drill");
|
||||||
|
String after = s.toString();
|
||||||
|
assertThat(after, is(not(equalTo(before))));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,33 @@
|
|||||||
|
package observer_pattern_tests.submersible.equipment.topographicalmapper;
|
||||||
|
|
||||||
|
import static org.hamcrest.CoreMatchers.equalTo;
|
||||||
|
import static org.hamcrest.CoreMatchers.is;
|
||||||
|
import static org.hamcrest.CoreMatchers.not;
|
||||||
|
import org.junit.Test;
|
||||||
|
import static org.junit.Assert.*;
|
||||||
|
import seabedexplorer.submersible.ROV;
|
||||||
|
import seabedexplorer.submersible.equipment.topographicalmapper.Laser;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author Dylan Currey
|
||||||
|
*/
|
||||||
|
public class LaserTest {
|
||||||
|
|
||||||
|
public LaserTest() {
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test of update method, of class Laser.
|
||||||
|
*/
|
||||||
|
@Test
|
||||||
|
public void testUpdate() {
|
||||||
|
System.out.println("update");
|
||||||
|
Laser s = new Laser(new ROV(),1);
|
||||||
|
String before = s.toString();
|
||||||
|
s.update("laser");
|
||||||
|
String after = s.toString();
|
||||||
|
assertThat(after, is(not(equalTo(before))));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,33 @@
|
|||||||
|
package observer_pattern_tests.submersible.equipment.topographicalmapper;
|
||||||
|
|
||||||
|
import static org.hamcrest.CoreMatchers.equalTo;
|
||||||
|
import static org.hamcrest.CoreMatchers.is;
|
||||||
|
import static org.hamcrest.CoreMatchers.not;
|
||||||
|
import org.junit.Test;
|
||||||
|
import static org.junit.Assert.*;
|
||||||
|
import seabedexplorer.submersible.ROV;
|
||||||
|
import seabedexplorer.submersible.equipment.topographicalmapper.Sonar;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author Dylan Currey
|
||||||
|
*/
|
||||||
|
public class SonarTest {
|
||||||
|
|
||||||
|
public SonarTest() {
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test of update method, of class Sonar.
|
||||||
|
*/
|
||||||
|
@Test
|
||||||
|
public void testUpdate() {
|
||||||
|
System.out.println("update");
|
||||||
|
Sonar s = new Sonar(new ROV());
|
||||||
|
String before = s.toString();
|
||||||
|
s.update("sonar");
|
||||||
|
String after = s.toString();
|
||||||
|
assertThat(after, is(not(equalTo(before))));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,33 @@
|
|||||||
|
package observer_pattern_tests.submersible.equipment.waterreadings;
|
||||||
|
|
||||||
|
import static org.hamcrest.CoreMatchers.equalTo;
|
||||||
|
import static org.hamcrest.CoreMatchers.is;
|
||||||
|
import static org.hamcrest.CoreMatchers.not;
|
||||||
|
import org.junit.Test;
|
||||||
|
import static org.junit.Assert.*;
|
||||||
|
import seabedexplorer.submersible.ROV;
|
||||||
|
import seabedexplorer.submersible.equipment.waterreadings.IndexOfRefraction;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author Dylan Currey
|
||||||
|
*/
|
||||||
|
public class IndexOfRefractionTest {
|
||||||
|
|
||||||
|
public IndexOfRefractionTest() {
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test of update method, of class IndexOfRefraction.
|
||||||
|
*/
|
||||||
|
@Test
|
||||||
|
public void testUpdate() {
|
||||||
|
System.out.println("update");
|
||||||
|
IndexOfRefraction s = new IndexOfRefraction(new ROV(),1);
|
||||||
|
String before = s.toString();
|
||||||
|
s.update("refraction");
|
||||||
|
String after = s.toString();
|
||||||
|
assertThat(after, is(not(equalTo(before))));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,31 @@
|
|||||||
|
package observer_pattern_tests.submersible.equipment.waterreadings;
|
||||||
|
|
||||||
|
import static org.hamcrest.CoreMatchers.*;
|
||||||
|
import static org.junit.Assert.*;
|
||||||
|
import org.junit.Test;
|
||||||
|
import seabedexplorer.submersible.ROV;
|
||||||
|
import seabedexplorer.submersible.equipment.waterreadings.PH;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author Dylan Currey
|
||||||
|
*/
|
||||||
|
public class PHTest {
|
||||||
|
|
||||||
|
public PHTest() {
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test of update method, of class PH.
|
||||||
|
*/
|
||||||
|
@Test
|
||||||
|
public void testUpdate() {
|
||||||
|
System.out.println("update");
|
||||||
|
PH s = new PH(new ROV());
|
||||||
|
String before = s.toString();
|
||||||
|
s.update("PH");
|
||||||
|
String after = s.toString();
|
||||||
|
assertThat(after, is(not(equalTo(before))));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,33 @@
|
|||||||
|
package observer_pattern_tests.submersible.equipment.waterreadings;
|
||||||
|
|
||||||
|
import static org.hamcrest.CoreMatchers.equalTo;
|
||||||
|
import static org.hamcrest.CoreMatchers.is;
|
||||||
|
import static org.hamcrest.CoreMatchers.not;
|
||||||
|
import org.junit.Test;
|
||||||
|
import static org.junit.Assert.*;
|
||||||
|
import seabedexplorer.submersible.ROV;
|
||||||
|
import seabedexplorer.submersible.equipment.waterreadings.Salinity;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author Dylan Currey
|
||||||
|
*/
|
||||||
|
public class SalinityTest {
|
||||||
|
|
||||||
|
public SalinityTest() {
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test of update method, of class Salinity.
|
||||||
|
*/
|
||||||
|
@Test
|
||||||
|
public void testUpdate() {
|
||||||
|
System.out.println("update");
|
||||||
|
Salinity s = new Salinity(new ROV());
|
||||||
|
String before = s.toString();
|
||||||
|
s.update("salinity");
|
||||||
|
String after = s.toString();
|
||||||
|
assertThat(after, is(not(equalTo(before))));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
76
test/observer_pattern_tests/vessel/VesselTest.java
Normal file
76
test/observer_pattern_tests/vessel/VesselTest.java
Normal file
@ -0,0 +1,76 @@
|
|||||||
|
package observer_pattern_tests.vessel;
|
||||||
|
|
||||||
|
import static org.junit.Assert.*;
|
||||||
|
import org.junit.Test;
|
||||||
|
import seabedexplorer.observer.Observer;
|
||||||
|
import seabedexplorer.submersible.AUV;
|
||||||
|
import seabedexplorer.submersible.MS;
|
||||||
|
import seabedexplorer.submersible.ROV;
|
||||||
|
import seabedexplorer.submersible.Submersible;
|
||||||
|
import seabedexplorer.util.submersible.SubmersibleUtil;
|
||||||
|
import seabedexplorer.vessel.Vessel;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author cdrbv
|
||||||
|
*/
|
||||||
|
public class VesselTest {
|
||||||
|
|
||||||
|
public VesselTest() {
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test of attach method, of class Vessel.
|
||||||
|
*/
|
||||||
|
@Test
|
||||||
|
public void testAttach() {
|
||||||
|
System.out.println("attach");
|
||||||
|
Observer AUV = new AUV();
|
||||||
|
Observer ROV = new ROV();
|
||||||
|
Observer MS = new MS();
|
||||||
|
Vessel v = new Vessel();
|
||||||
|
v.attach(AUV);
|
||||||
|
v.attach(ROV);
|
||||||
|
v.attach(MS);
|
||||||
|
final int expectedValue = 3;
|
||||||
|
assertEquals(expectedValue, v.getNoSubmersibles());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test of detach method, of class Vessel.
|
||||||
|
*/
|
||||||
|
@Test
|
||||||
|
public void testDetach() {
|
||||||
|
System.out.println("detach");
|
||||||
|
Vessel v = new Vessel();
|
||||||
|
Observer AUV = new AUV();
|
||||||
|
Observer ROV = new ROV();
|
||||||
|
Observer MS = new MS();
|
||||||
|
v.attach(AUV);
|
||||||
|
v.attach(ROV);
|
||||||
|
v.attach(MS);
|
||||||
|
v.detach(AUV);
|
||||||
|
v.detach(ROV);
|
||||||
|
v.detach(MS);
|
||||||
|
final int expectedValue = 0;
|
||||||
|
assertEquals(expectedValue, v.getNoSubmersibles());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test of updateObservers method, of class Vessel.
|
||||||
|
*/
|
||||||
|
@Test
|
||||||
|
public void testUpdateObservers() {
|
||||||
|
System.out.println("updateObservers");
|
||||||
|
Vessel v = new Vessel();
|
||||||
|
for(Submersible s: SubmersibleUtil.GenerateRandomSubmersibles(3))
|
||||||
|
{
|
||||||
|
v.attach(s);
|
||||||
|
}
|
||||||
|
boolean result = v.updateObservers("info");
|
||||||
|
assertTrue(result);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
19
test/state_pattern_tests/StateTransitionTest.java
Normal file
19
test/state_pattern_tests/StateTransitionTest.java
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
package state_pattern_tests;
|
||||||
|
|
||||||
|
import org.junit.Test;
|
||||||
|
import static org.junit.Assert.*;
|
||||||
|
import seabedexplorer.submersible.ROV;
|
||||||
|
import seabedexplorer.submersible.equipment.locationtracking.Location;
|
||||||
|
|
||||||
|
public class StateTransitionTest {
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void StateTransitionTest()
|
||||||
|
{
|
||||||
|
ROV rov = new ROV();
|
||||||
|
rov.move(new Location(5, 5, 5));
|
||||||
|
assertEquals(rov.getStateName(), "Idle");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
71
test/state_pattern_tests/states/BusyActionStateTest.java
Normal file
71
test/state_pattern_tests/states/BusyActionStateTest.java
Normal file
@ -0,0 +1,71 @@
|
|||||||
|
package state_pattern_tests.states;
|
||||||
|
|
||||||
|
import org.junit.Test;
|
||||||
|
import static org.junit.Assert.*;
|
||||||
|
import seabedexplorer.submersible.ROV;
|
||||||
|
import seabedexplorer.submersible.equipment.locationtracking.Location;
|
||||||
|
import seabedexplorer.submersible.state.states.BusyActionState;
|
||||||
|
import seabedexplorer.submersible.state.states.IdleState;
|
||||||
|
|
||||||
|
public class BusyActionStateTest {
|
||||||
|
|
||||||
|
public BusyActionStateTest() {
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void BusyActionStateTestCanMove()
|
||||||
|
{
|
||||||
|
BusyActionState is = new BusyActionState();
|
||||||
|
assertFalse(is.canMove());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void BusyActionStateTestMove()
|
||||||
|
{
|
||||||
|
BusyActionState is = new BusyActionState();
|
||||||
|
is.submersibleInstance(new ROV());
|
||||||
|
assertFalse(is.move(new Location(5, 5, 5)));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void BusyActionStatesTestStopMove()
|
||||||
|
{
|
||||||
|
BusyActionState is = new BusyActionState();
|
||||||
|
assertFalse(is.stopMove());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void BusyActionStateString()
|
||||||
|
{
|
||||||
|
BusyActionState is = new BusyActionState();
|
||||||
|
assertEquals(is.toString(), "Busy (Action in progress)");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void BusyActionStateReturnToVesel()
|
||||||
|
{
|
||||||
|
BusyActionState is = new BusyActionState();
|
||||||
|
assertFalse(is.returnToVessel());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void BusyActionStateCollectWater()
|
||||||
|
{
|
||||||
|
BusyActionState is = new BusyActionState();
|
||||||
|
assertFalse(is.collectWater());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void BusyActionStateCollectMaterial()
|
||||||
|
{
|
||||||
|
BusyActionState is = new BusyActionState();
|
||||||
|
assertFalse(is.collectMaterial());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void BusyActionStateCollectMapping()
|
||||||
|
{
|
||||||
|
BusyActionState is = new BusyActionState();
|
||||||
|
assertFalse(is.collectMappingData());
|
||||||
|
}
|
||||||
|
}
|
65
test/state_pattern_tests/states/BusyMoveStateTest.java
Normal file
65
test/state_pattern_tests/states/BusyMoveStateTest.java
Normal file
@ -0,0 +1,65 @@
|
|||||||
|
package state_pattern_tests.states;
|
||||||
|
|
||||||
|
import org.junit.Test;
|
||||||
|
import static org.junit.Assert.*;
|
||||||
|
import seabedexplorer.submersible.ROV;
|
||||||
|
import seabedexplorer.submersible.equipment.locationtracking.Location;
|
||||||
|
import seabedexplorer.submersible.state.states.BusyMoveState;
|
||||||
|
import seabedexplorer.util.movement.MovementEmulation;
|
||||||
|
|
||||||
|
|
||||||
|
public class BusyMoveStateTest {
|
||||||
|
|
||||||
|
public BusyMoveStateTest() {
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void BusyMoveStateTestCanMove()
|
||||||
|
{
|
||||||
|
BusyMoveState is = new BusyMoveState(new MovementEmulation(new ROV(), new Location(5, 5, 5)));
|
||||||
|
assertFalse(is.canMove());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void BusyMoveStateTestMove()
|
||||||
|
{
|
||||||
|
BusyMoveState is = new BusyMoveState(new MovementEmulation(new ROV(), new Location(5, 5, 5)));
|
||||||
|
assertFalse(is.move(new Location(5, 5, 5)));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void BusyMoveStateString()
|
||||||
|
{
|
||||||
|
BusyMoveState is = new BusyMoveState(new MovementEmulation(new ROV(), new Location(5, 5, 5)));
|
||||||
|
assertEquals(is.toString(), "Busy (Movement in progress)");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void BusyMoveStateReturnToVesel()
|
||||||
|
{
|
||||||
|
BusyMoveState is = new BusyMoveState(new MovementEmulation(new ROV(), new Location(5, 5, 5)));
|
||||||
|
assertFalse(is.returnToVessel());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void BusyMoveStateCollectWater()
|
||||||
|
{
|
||||||
|
BusyMoveState is = new BusyMoveState(new MovementEmulation(new ROV(), new Location(5, 5, 5)));
|
||||||
|
assertFalse(is.collectWater());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void BusyMoveStateCollectMaterial()
|
||||||
|
{
|
||||||
|
BusyMoveState is = new BusyMoveState(new MovementEmulation(new ROV(), new Location(5, 5, 5)));
|
||||||
|
assertFalse(is.collectMaterial());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void BusyMoveStateCollectMapping()
|
||||||
|
{
|
||||||
|
BusyMoveState is = new BusyMoveState(new MovementEmulation(new ROV(), new Location(5, 5, 5)));
|
||||||
|
assertFalse(is.collectMappingData());
|
||||||
|
}
|
||||||
|
}
|
71
test/state_pattern_tests/states/DeployStateTest.java
Normal file
71
test/state_pattern_tests/states/DeployStateTest.java
Normal file
@ -0,0 +1,71 @@
|
|||||||
|
package state_pattern_tests.states;
|
||||||
|
|
||||||
|
import org.junit.Test;
|
||||||
|
import static org.junit.Assert.*;
|
||||||
|
import seabedexplorer.submersible.ROV;
|
||||||
|
import seabedexplorer.submersible.equipment.locationtracking.Location;
|
||||||
|
import seabedexplorer.submersible.state.states.DeployState;
|
||||||
|
import seabedexplorer.submersible.state.states.IdleState;
|
||||||
|
|
||||||
|
public class DeployStateTest {
|
||||||
|
|
||||||
|
public DeployStateTest() {
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void DeployStateTestCanMove()
|
||||||
|
{
|
||||||
|
DeployState is = new DeployState();
|
||||||
|
assertFalse(is.canMove());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void DeployStateTestMove()
|
||||||
|
{
|
||||||
|
DeployState is = new DeployState();
|
||||||
|
is.submersibleInstance(new ROV());
|
||||||
|
assertFalse(is.move(new Location(5, 5, 5)));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void DeployStatesTestStopMove()
|
||||||
|
{
|
||||||
|
DeployState is = new DeployState();
|
||||||
|
assertFalse(is.stopMove());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void DeployStateString()
|
||||||
|
{
|
||||||
|
DeployState is = new DeployState();
|
||||||
|
assertEquals(is.toString(), "Deployed");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void DeployStateReturnToVesel()
|
||||||
|
{
|
||||||
|
DeployState is = new DeployState();
|
||||||
|
assertFalse(is.returnToVessel());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void DeployStateCollectWater()
|
||||||
|
{
|
||||||
|
DeployState is = new DeployState();
|
||||||
|
assertFalse(is.collectWater());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void DeployStateCollectMaterial()
|
||||||
|
{
|
||||||
|
DeployState is = new DeployState();
|
||||||
|
assertFalse(is.collectMaterial());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void DeployStateCollectMapping()
|
||||||
|
{
|
||||||
|
DeployState is = new DeployState();
|
||||||
|
assertFalse(is.collectMappingData());
|
||||||
|
}
|
||||||
|
}
|
71
test/state_pattern_tests/states/DockedStateTest.java
Normal file
71
test/state_pattern_tests/states/DockedStateTest.java
Normal file
@ -0,0 +1,71 @@
|
|||||||
|
package state_pattern_tests.states;
|
||||||
|
|
||||||
|
import org.junit.Test;
|
||||||
|
import static org.junit.Assert.*;
|
||||||
|
import seabedexplorer.submersible.ROV;
|
||||||
|
import seabedexplorer.submersible.equipment.locationtracking.Location;
|
||||||
|
import seabedexplorer.submersible.state.states.DockedState;
|
||||||
|
import seabedexplorer.submersible.state.states.IdleState;
|
||||||
|
|
||||||
|
public class DockedStateTest {
|
||||||
|
|
||||||
|
public DockedStateTest() {
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void DockedStateTestCanMove()
|
||||||
|
{
|
||||||
|
DockedState is = new DockedState();
|
||||||
|
assertTrue(is.canMove());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void DockedStateTestMove()
|
||||||
|
{
|
||||||
|
DockedState is = new DockedState();
|
||||||
|
is.submersibleInstance(new ROV());
|
||||||
|
assertTrue(is.move(new Location(5, 5, 5)));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void DockedStatesTestStopMove()
|
||||||
|
{
|
||||||
|
DockedState is = new DockedState();
|
||||||
|
assertFalse(is.stopMove());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void DockedStateString()
|
||||||
|
{
|
||||||
|
DockedState is = new DockedState();
|
||||||
|
assertEquals(is.toString(), "Docked");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void DockedStateReturnToVesel()
|
||||||
|
{
|
||||||
|
DockedState is = new DockedState();
|
||||||
|
assertFalse(is.returnToVessel());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void DockedStateCollectWater()
|
||||||
|
{
|
||||||
|
DockedState is = new DockedState();
|
||||||
|
assertFalse(is.collectWater());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void DockedStateCollectMaterial()
|
||||||
|
{
|
||||||
|
DockedState is = new DockedState();
|
||||||
|
assertFalse(is.collectMaterial());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void DockedStateCollectMapping()
|
||||||
|
{
|
||||||
|
DockedState is = new DockedState();
|
||||||
|
assertFalse(is.collectMappingData());
|
||||||
|
}
|
||||||
|
}
|
71
test/state_pattern_tests/states/IdleStateTest.java
Normal file
71
test/state_pattern_tests/states/IdleStateTest.java
Normal file
@ -0,0 +1,71 @@
|
|||||||
|
package state_pattern_tests.states;
|
||||||
|
|
||||||
|
import org.junit.Test;
|
||||||
|
import static org.junit.Assert.*;
|
||||||
|
import seabedexplorer.submersible.ROV;
|
||||||
|
import seabedexplorer.submersible.equipment.locationtracking.Location;
|
||||||
|
import seabedexplorer.submersible.state.states.IdleState;
|
||||||
|
|
||||||
|
public class IdleStateTest {
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void IdleStateTestCanMove()
|
||||||
|
{
|
||||||
|
IdleState is = new IdleState();
|
||||||
|
assertTrue(is.canMove());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void IdleStateTestMove()
|
||||||
|
{
|
||||||
|
IdleState is = new IdleState();
|
||||||
|
is.submersibleInstance(new ROV());
|
||||||
|
assertTrue(is.move(new Location(5, 5, 5)));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void IdleStatesTestStopMove()
|
||||||
|
{
|
||||||
|
IdleState is = new IdleState();
|
||||||
|
assertFalse(is.stopMove());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void IdleStateString()
|
||||||
|
{
|
||||||
|
IdleState is = new IdleState();
|
||||||
|
assertEquals(is.toString(), "Idle");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void IdleStateReturnToVesel()
|
||||||
|
{
|
||||||
|
IdleState is = new IdleState();
|
||||||
|
is.submersibleInstance(new ROV());
|
||||||
|
assertTrue(is.returnToVessel());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void IdleStateCollectWater()
|
||||||
|
{
|
||||||
|
IdleState is = new IdleState();
|
||||||
|
is.submersibleInstance(new ROV());
|
||||||
|
assertTrue(is.collectWater());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void IdleStateCollectMaterial()
|
||||||
|
{
|
||||||
|
IdleState is = new IdleState();
|
||||||
|
is.submersibleInstance(new ROV());
|
||||||
|
assertTrue(is.collectMaterial());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void IdleStateCollectMapping()
|
||||||
|
{
|
||||||
|
IdleState is = new IdleState();
|
||||||
|
is.submersibleInstance(new ROV());
|
||||||
|
assertTrue(is.collectMappingData());
|
||||||
|
}
|
||||||
|
}
|
74
test/strategy_pattern_tests/ChemicalScannerTest.java
Normal file
74
test/strategy_pattern_tests/ChemicalScannerTest.java
Normal file
@ -0,0 +1,74 @@
|
|||||||
|
/*
|
||||||
|
* To change this license header, choose License Headers in Project Properties.
|
||||||
|
* To change this template file, choose Tools | Templates
|
||||||
|
* and open the template in the editor.
|
||||||
|
*/
|
||||||
|
package strategy_pattern_tests;
|
||||||
|
|
||||||
|
import static org.junit.Assert.*;
|
||||||
|
import org.junit.Test;
|
||||||
|
import seabedexplorer.data.Data;
|
||||||
|
import seabedexplorer.data.MaterialSample;
|
||||||
|
import seabedexplorer.submersible.ROV;
|
||||||
|
import seabedexplorer.submersible.equipment.materialsampler.ChemicalScanner;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author Super
|
||||||
|
*/
|
||||||
|
public class ChemicalScannerTest {
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void validMassTest() {
|
||||||
|
ROV submersible = new ROV();
|
||||||
|
|
||||||
|
ChemicalScanner equipment = new ChemicalScanner(submersible, 0.5);
|
||||||
|
|
||||||
|
for (int i = 0; i < 100; i++)
|
||||||
|
equipment.collectData();
|
||||||
|
|
||||||
|
Data[] data = equipment.getData().toArray(new Data[100]);
|
||||||
|
|
||||||
|
for (int i = 0; i < 100; i++) {
|
||||||
|
MaterialSample current = (MaterialSample) data[i];
|
||||||
|
System.out.println(current.getMass());
|
||||||
|
assertTrue(current.getMass() >= 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void validDensityTest() {
|
||||||
|
ROV submersible = new ROV();
|
||||||
|
|
||||||
|
ChemicalScanner equipment = new ChemicalScanner(submersible, 0.5);
|
||||||
|
|
||||||
|
for (int i = 0; i < 100; i++)
|
||||||
|
equipment.collectData();
|
||||||
|
|
||||||
|
Data[] data = equipment.getData().toArray(new Data[100]);
|
||||||
|
|
||||||
|
for (int i = 0; i < 100; i++) {
|
||||||
|
MaterialSample current = (MaterialSample) data[i];
|
||||||
|
System.out.println(current.getDensity());
|
||||||
|
assertTrue(current.getDensity() >= 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void correctDensityTest() {
|
||||||
|
ROV submersible = new ROV();
|
||||||
|
|
||||||
|
ChemicalScanner equipment = new ChemicalScanner(submersible, 0.5);
|
||||||
|
|
||||||
|
for (int i = 0; i < 100; i++)
|
||||||
|
equipment.collectData();
|
||||||
|
|
||||||
|
Data[] data = equipment.getData().toArray(new Data[100]);
|
||||||
|
|
||||||
|
for (int i = 0; i < 100; i++) {
|
||||||
|
MaterialSample current = (MaterialSample) data[i];
|
||||||
|
System.out.println(current.getMass() + " " + current.getDensity());
|
||||||
|
assertEquals(current.getMass(),current.getDensity() * 0.5, 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
74
test/strategy_pattern_tests/HotFluidSamplerTest.java
Normal file
74
test/strategy_pattern_tests/HotFluidSamplerTest.java
Normal file
@ -0,0 +1,74 @@
|
|||||||
|
/*
|
||||||
|
* To change this license header, choose License Headers in Project Properties.
|
||||||
|
* To change this template file, choose Tools | Templates
|
||||||
|
* and open the template in the editor.
|
||||||
|
*/
|
||||||
|
package strategy_pattern_tests;
|
||||||
|
|
||||||
|
import static org.junit.Assert.*;
|
||||||
|
import org.junit.Test;
|
||||||
|
import seabedexplorer.data.Data;
|
||||||
|
import seabedexplorer.data.MaterialSample;
|
||||||
|
import seabedexplorer.submersible.ROV;
|
||||||
|
import seabedexplorer.submersible.equipment.materialsampler.HotFluidSampler;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author Super
|
||||||
|
*/
|
||||||
|
public class HotFluidSamplerTest {
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void validMassTest() {
|
||||||
|
ROV submersible = new ROV();
|
||||||
|
|
||||||
|
HotFluidSampler equipment = new HotFluidSampler(submersible, 0.5);
|
||||||
|
|
||||||
|
for (int i = 0; i < 100; i++)
|
||||||
|
equipment.collectData();
|
||||||
|
|
||||||
|
Data[] data = equipment.getData().toArray(new Data[100]);
|
||||||
|
|
||||||
|
for (int i = 0; i < 100; i++) {
|
||||||
|
MaterialSample current = (MaterialSample) data[i];
|
||||||
|
System.out.println(current.getMass());
|
||||||
|
assertTrue(current.getMass() >= 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void validDensityTest() {
|
||||||
|
ROV submersible = new ROV();
|
||||||
|
|
||||||
|
HotFluidSampler equipment = new HotFluidSampler(submersible, 0.5);
|
||||||
|
|
||||||
|
for (int i = 0; i < 100; i++)
|
||||||
|
equipment.collectData();
|
||||||
|
|
||||||
|
Data[] data = equipment.getData().toArray(new Data[100]);
|
||||||
|
|
||||||
|
for (int i = 0; i < 100; i++) {
|
||||||
|
MaterialSample current = (MaterialSample) data[i];
|
||||||
|
System.out.println(current.getDensity());
|
||||||
|
assertTrue(current.getDensity() >= 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void correctDensityTest() {
|
||||||
|
ROV submersible = new ROV();
|
||||||
|
|
||||||
|
HotFluidSampler equipment = new HotFluidSampler(submersible, 0.5);
|
||||||
|
|
||||||
|
for (int i = 0; i < 100; i++)
|
||||||
|
equipment.collectData();
|
||||||
|
|
||||||
|
Data[] data = equipment.getData().toArray(new Data[100]);
|
||||||
|
|
||||||
|
for (int i = 0; i < 100; i++) {
|
||||||
|
MaterialSample current = (MaterialSample) data[i];
|
||||||
|
System.out.println(current.getMass() + " " + current.getDensity());
|
||||||
|
assertEquals(current.getMass(),current.getDensity() * 0.5, 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
74
test/strategy_pattern_tests/IndexOfRefractionTest.java
Normal file
74
test/strategy_pattern_tests/IndexOfRefractionTest.java
Normal file
@ -0,0 +1,74 @@
|
|||||||
|
/*
|
||||||
|
* To change this license header, choose License Headers in Project Properties.
|
||||||
|
* To change this template file, choose Tools | Templates
|
||||||
|
* and open the template in the editor.
|
||||||
|
*/
|
||||||
|
package strategy_pattern_tests;
|
||||||
|
|
||||||
|
import static org.junit.Assert.*;
|
||||||
|
import org.junit.Test;
|
||||||
|
import seabedexplorer.data.Data;
|
||||||
|
import seabedexplorer.data.IndexOfRefractionReading;
|
||||||
|
import seabedexplorer.submersible.ROV;
|
||||||
|
import seabedexplorer.submersible.equipment.waterreadings.IndexOfRefraction;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author Super
|
||||||
|
*/
|
||||||
|
public class IndexOfRefractionTest {
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void validAngleTest() {
|
||||||
|
ROV submersible = new ROV();
|
||||||
|
|
||||||
|
IndexOfRefraction equipment = new IndexOfRefraction(submersible, 30);
|
||||||
|
|
||||||
|
for (int i = 0; i < 100; i++)
|
||||||
|
equipment.collectData();
|
||||||
|
|
||||||
|
Data[] data = equipment.getData().toArray(new Data[100]);
|
||||||
|
|
||||||
|
for (int i = 0; i < 100; i++) {
|
||||||
|
IndexOfRefractionReading current = (IndexOfRefractionReading) data[i];
|
||||||
|
System.out.println(current.getAngleOfRefraction());
|
||||||
|
assertTrue(current.getAngleOfRefraction() >= 0 && current.getAngleOfRefraction() <= 90);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void validIndexTest() {
|
||||||
|
ROV submersible = new ROV();
|
||||||
|
|
||||||
|
IndexOfRefraction equipment = new IndexOfRefraction(submersible,30);
|
||||||
|
|
||||||
|
for (int i = 0; i < 100; i++)
|
||||||
|
equipment.collectData();
|
||||||
|
|
||||||
|
Data[] data = equipment.getData().toArray(new Data[100]);
|
||||||
|
|
||||||
|
for (int i = 0; i < 100; i++) {
|
||||||
|
IndexOfRefractionReading current = (IndexOfRefractionReading) data[i];
|
||||||
|
System.out.println(current.getIndexOfRefraction());
|
||||||
|
assertTrue(current.getAngleOfRefraction() >= 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void correctIndexTest() {
|
||||||
|
ROV submersible = new ROV();
|
||||||
|
|
||||||
|
IndexOfRefraction equipment = new IndexOfRefraction(submersible,30);
|
||||||
|
|
||||||
|
for (int i = 0; i < 100; i++)
|
||||||
|
equipment.collectData();
|
||||||
|
|
||||||
|
Data[] data = equipment.getData().toArray(new Data[100]);
|
||||||
|
|
||||||
|
for (int i = 0; i < 100; i++) {
|
||||||
|
IndexOfRefractionReading current = (IndexOfRefractionReading) data[i];
|
||||||
|
System.out.println(current.getAngleOfRefraction() + " " + current.getIndexOfRefraction());
|
||||||
|
assertEquals(current.getIndexOfRefraction(), 30 / current.getAngleOfRefraction(),0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
74
test/strategy_pattern_tests/LaserTest.java
Normal file
74
test/strategy_pattern_tests/LaserTest.java
Normal file
@ -0,0 +1,74 @@
|
|||||||
|
/*
|
||||||
|
* To change this license header, choose License Headers in Project Properties.
|
||||||
|
* To change this template file, choose Tools | Templates
|
||||||
|
* and open the template in the editor.
|
||||||
|
*/
|
||||||
|
package strategy_pattern_tests;
|
||||||
|
|
||||||
|
import static org.junit.Assert.*;
|
||||||
|
import org.junit.Test;
|
||||||
|
import seabedexplorer.data.Data;
|
||||||
|
import seabedexplorer.data.LaserReading;
|
||||||
|
import seabedexplorer.submersible.ROV;
|
||||||
|
import seabedexplorer.submersible.equipment.topographicalmapper.Laser;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author Super
|
||||||
|
*/
|
||||||
|
public class LaserTest {
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void validAngleTest() {
|
||||||
|
ROV submersible = new ROV();
|
||||||
|
|
||||||
|
Laser equipment = new Laser(submersible, 0.5);
|
||||||
|
|
||||||
|
for (int i = 0; i < 100; i++)
|
||||||
|
equipment.collectData();
|
||||||
|
|
||||||
|
Data[] data = equipment.getData().toArray(new Data[100]);
|
||||||
|
|
||||||
|
for (int i = 0; i < 100; i++) {
|
||||||
|
LaserReading current = (LaserReading) data[i];
|
||||||
|
System.out.println(current.getAngle());
|
||||||
|
assertTrue(current.getAngle() >= 0 && current.getAngle() <= 90);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void correctDepthTest() {
|
||||||
|
ROV submersible = new ROV();
|
||||||
|
|
||||||
|
Laser equipment = new Laser(submersible,0.5);
|
||||||
|
|
||||||
|
for (int i = 0; i < 100; i++)
|
||||||
|
equipment.collectData();
|
||||||
|
|
||||||
|
Data[] data = equipment.getData().toArray(new Data[100]);
|
||||||
|
|
||||||
|
for (int i = 0; i < 100; i++) {
|
||||||
|
LaserReading current = (LaserReading) data[i];
|
||||||
|
System.out.println(current.getAngle() + " " + current.getDepth());
|
||||||
|
assertEquals(current.getDepth(), 0.5 / Math.tan(current.getAngle() / (180/Math.PI)),0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void validDepthTest() {
|
||||||
|
ROV submersible = new ROV();
|
||||||
|
|
||||||
|
Laser equipment = new Laser(submersible, 0.5);
|
||||||
|
|
||||||
|
for (int i = 0; i < 100; i++)
|
||||||
|
equipment.collectData();
|
||||||
|
|
||||||
|
Data[] data = equipment.getData().toArray(new Data[100]);
|
||||||
|
|
||||||
|
for (int i = 0; i < 100; i++) {
|
||||||
|
LaserReading current = (LaserReading) data[i];
|
||||||
|
System.out.println(current.getDepth());
|
||||||
|
assertTrue(current.getDepth() >= 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
38
test/strategy_pattern_tests/PhotosensorTest.java
Normal file
38
test/strategy_pattern_tests/PhotosensorTest.java
Normal file
@ -0,0 +1,38 @@
|
|||||||
|
/*
|
||||||
|
* To change this license header, choose License Headers in Project Properties.
|
||||||
|
* To change this template file, choose Tools | Templates
|
||||||
|
* and open the template in the editor.
|
||||||
|
*/
|
||||||
|
package strategy_pattern_tests;
|
||||||
|
|
||||||
|
import static org.junit.Assert.*;
|
||||||
|
import org.junit.Test;
|
||||||
|
import seabedexplorer.data.Data;
|
||||||
|
import seabedexplorer.data.PhotoSensorReading;
|
||||||
|
import seabedexplorer.submersible.ROV;
|
||||||
|
import seabedexplorer.submersible.equipment.PhotoSensor;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author Super
|
||||||
|
*/
|
||||||
|
public class PhotosensorTest {
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void validPhotosensorTest() {
|
||||||
|
ROV submersible = new ROV();
|
||||||
|
|
||||||
|
PhotoSensor equipment = new PhotoSensor(submersible);
|
||||||
|
|
||||||
|
for (int i = 0; i < 100; i++)
|
||||||
|
equipment.collectData();
|
||||||
|
|
||||||
|
Data[] data = equipment.getData().toArray(new Data[100]);
|
||||||
|
|
||||||
|
for (int i = 0; i < 100; i++) {
|
||||||
|
PhotoSensorReading current = (PhotoSensorReading) data[i];
|
||||||
|
System.out.println(current.getReading());
|
||||||
|
assertTrue(current.getReading() >= 10 && current.getReading() <= 1000000);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user