Commit 1db56d00 authored by firegnom's avatar firegnom
Browse files

new constructor to Gas , which sets mod automatically

added interface comparable to SegmentAbstract
parent 13b9a120
......@@ -76,8 +76,18 @@ public class Gas implements Comparable<Gas>, Serializable, Cloneable
}
/**
/** Constructor for Gas objects. Fractions must add to <= 1.0. Remainder assumed Nitrogen.
* If constructed with erroneous data is set up as air.
* <br><br>
* Mod is set to be maximum mod for specified fO2
*
* @param fHe Fraction of helium (0.0 - 1.0)
* @param fO2 Fraction of Oxygen (0.0 - 1.0)
*/
public Gas(double fHe, double fO2) {
this(fHe, fO2, GasUtils.getMaxMod(fO2));
}
/**
* Override the clone method to make it public
* @return Cloned Gas object
* @throws CloneNotSupportedException Never thrown and required for Cloneable interface
......
......@@ -51,7 +51,7 @@ public class Prefs implements Serializable
public final static int IMPERIAL=1;
public final static double ALTITUDE_MAX = 3000;
public final static double METERS_TO_FEET = 3.3;
private int debug = MvplanInstance.getMvplan().getDebug();
private int debug = 0;
private int units; // 0 = metric or 1 = imperial
private boolean disableModUpdate; // Automatically update MODS on units switch
......@@ -146,7 +146,7 @@ public class Prefs implements Serializable
public void setDefaultPrefs()
{
MvplanInstance.getMvplan().getDebug();
// Set defaults
units = METRIC;
disableModUpdate=false;
......
......@@ -28,7 +28,7 @@ import java.io.*;
import mvplan.gas.Gas;
import mvplan.main.MvplanInstance;
public abstract class SegmentAbstract implements Serializable, Cloneable
public abstract class SegmentAbstract implements Serializable, Cloneable , Comparable<SegmentAbstract>
{
double depth=0.0; // Depth of segment (typically end)
double setpoint=0.0; // For CCR (=0 for Open Circuit)
......@@ -213,6 +213,26 @@ public abstract class SegmentAbstract implements Serializable, Cloneable
* @return Volume of gas used
*/
public abstract double gasUsed();
public int compareTo(SegmentAbstract o) {
int compare = Double.compare(depth, o.depth);
if (compare != 0) return compare;
compare = Double.compare(time, o.time);
if (compare != 0) return compare;
compare = Double.compare(setpoint, o.setpoint);
if (compare != 0) return compare;
if (gas == null){
if (o.gas != null) return 1;
}else{
compare = gas.compareTo(o.gas);
if (compare != 0) return compare;
}
compare = Boolean.compare(enable, o.enable);
if (compare != 0) return compare;
compare = Integer.compare(type, o.type);
if (compare != 0) return compare;
return 0;
}
}
......@@ -27,7 +27,7 @@ package mvplan.segments;
import mvplan.gas.Gas;
import mvplan.main.MvplanInstance;
public class SegmentDive extends SegmentAbstract
public class SegmentDive extends SegmentAbstract
{
/** Constructor for objects of class SegmentDive
......@@ -79,5 +79,7 @@ public class SegmentDive extends SegmentAbstract
depth, timeMins, timeSeconds, runTime, gas.toString(), setpoint, getEnd());
}
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment