Commit 9c33aa54 authored by firegnom's avatar firegnom
Browse files

- added new preference ocMode

- increased limits to 130m to be close to ostc computer
parent 1db56d00
......@@ -192,7 +192,7 @@ public class Profile
currentGas = s.getGas();
Collections.sort(gases); // Sort gases based on MOD, the Gas natural order
currentDepth=0.0;
ppO2=s.getSetpoint(); // Set initial ppO2 based on first segment
ppO2= prefs.isOcMode()?0.0:s.getSetpoint(); // Set initial ppO2 based on first segment
//Determine if we are Open or Closed circuit
if (ppO2==0.0)
closedCircuit=false;
......@@ -225,9 +225,9 @@ public class Profile
}
// Now at desired depth so process dive segments.
currentDepth=sd.getDepth(); // Reset current depth
ppO2=sd.getSetpoint(); // Set ppO2
currentGas=s.getGas(); // Set gas used
currentDepth=sd.getDepth(); // Reset current depth
ppO2=prefs.isOcMode()?0.0:sd.getSetpoint(); // Set ppO2
currentGas=s.getGas(); // Set gas used
// Process segment.
if (sd.getTime() > 0) { // Only do this if it is not a waypoint.
// Interpret first segment time as runtime or segment time depending on runtimeFlag
......@@ -515,6 +515,15 @@ public class Profile
}
return gasSwitch;
}
/**
* Gets the prefs used for this profile calculation.
*
* @return the prefs
*/
public Prefs getPrefs() {
return prefs;
}
}
......
......@@ -155,22 +155,58 @@ public class TextProfilePrinter extends ProfilePrinter <StringBuffer>{
textArea.append(" "+profile.getModel().getModelName());
textArea.append("\n");
printAltitude();
textArea.append(" "+MvplanInstance.getPrefs().getDepthShortString()+" "+mvplan.getResource("mvplan.gui.text.ProfilePrinter.heading.text")+'\n');
boolean ocMode = profile.getPrefs().isOcMode();
if (ocMode){
textArea.append(" "+MvplanInstance.getPrefs().getDepthShortString()+" "+mvplan.getResource("mvplan.gui.text.ProfilePrinter.heading.textNoSP")+'\n');
}else{
textArea.append(" "+MvplanInstance.getPrefs().getDepthShortString()+" "+mvplan.getResource("mvplan.gui.text.ProfilePrinter.heading.text")+'\n');
}
if (ocMode){
textArea.append("========================"+'\n');
// "- 120 00:00 000 88/88
}else{
textArea.append("=============================="+'\n');
// "- 120 00:00 000 88/88 1.30
// "- 120 00:00 000 88/88 1.30
}
for (SegmentAbstract s: profile.getProfile()){
segTimeMins=(int)s.getTime();
segTimeSeconds = (int)((s.getTime() - (double)segTimeMins)*60.0);
segTimeMins = (int) s.getTime();
segTimeSeconds = (int) ((s.getTime() - (double) segTimeMins) * 60.0);
if ((s.getDepth()-(int)s.getDepth())>0) // Do we have non-integer depth ?
textArea.append(String.format("%1$s %2$03.1f %3$02d:%4$02d %5$03.0f %6$5s %7$3.1f\n",
s.getTypeString(),s.getDepth(), segTimeMins,segTimeSeconds,s.getRunTime(),s.getGas().getShortName() ,s.getSetpoint() ));
else
textArea.append(String.format("%1$s %2$03.0f %3$02d:%4$02d %5$03.0f %6$5s %7$3.1f\n",
s.getTypeString(),s.getDepth(), segTimeMins,segTimeSeconds,s.getRunTime(),s.getGas().getShortName() ,s.getSetpoint() ));
}
if ((s.getDepth() - (int) s.getDepth()) > 0) { // Do we have
// non-integer depth
// ?
if (ocMode) {
textArea.append(String.format(
"%1$s %2$03.1f %3$02d:%4$02d %5$03.0f %6$5s\n",
s.getTypeString(), s.getDepth(), segTimeMins,
segTimeSeconds, s.getRunTime(), s.getGas()
.getShortName()));
} else {
textArea.append(String
.format("%1$s %2$03.1f %3$02d:%4$02d %5$03.0f %6$5s %7$3.1f\n",
s.getTypeString(), s.getDepth(),
segTimeMins, segTimeSeconds,
s.getRunTime(), s.getGas().getShortName(),
s.getSetpoint()));
}
} else {
if (ocMode) {
textArea.append(String
.format("%1$s %2$03.0f %3$02d:%4$02d %5$03.0f %6$5s\n",
s.getTypeString(), s.getDepth(),
segTimeMins, segTimeSeconds,
s.getRunTime(), s.getGas().getShortName()));
} else {
textArea.append(String
.format("%1$s %2$03.0f %3$02d:%4$02d %5$03.0f %6$5s %7$3.1f\n",
s.getTypeString(), s.getDepth(),
segTimeMins, segTimeSeconds,
s.getRunTime(), s.getGas().getShortName(),
s.getSetpoint()));
}
}
}
doGasUsage();
}
......
......@@ -26,17 +26,18 @@
*/
package mvplan.prefs;
import java.io.*;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.Iterator;
import java.util.List;
import java.util.Locale;
import mvplan.gas.Gas;
import mvplan.main.MvplanInstance;
import mvplan.segments.SegmentAbstract;
import mvplan.segments.SegmentDive;
import java.util.Date;
import java.util.Calendar;
import mvplan.main.MvplanInstance;
import mvplan.util.PressureConverter;
public class Prefs implements Serializable
......@@ -119,6 +120,9 @@ public class Prefs implements Serializable
private String modelClass; // Deco model class name
private double heliumNarcoticLevel; // is helium a narcotic gas in END calculations level of helium narcosis
private double oxygenNarcoticLevel; // is oxygen a narcotic gas in END calculations level of oxygen narcosis
private boolean ocMode; // open circuit mode even if segment have setPoint stored it won't be
// taken in to consideration. Currently used only in aScuba.
/*
......@@ -216,6 +220,7 @@ public class Prefs implements Serializable
modelClass="mvplan.model.ZHL16B";
heliumNarcoticLevel = 0.23;
oxygenNarcoticLevel = 1;
ocMode = false;
}
private void setLimits(boolean limits){
......@@ -231,9 +236,9 @@ public class Prefs implements Serializable
gfMax=0.95;
}
if(units==METRIC)
maxDepth = limits ? 200.0 : 100.0;
maxDepth = limits ? 200.0 : 130.0;
else
maxDepth= limits ? 660.0 : 330.0;
maxDepth= limits ? 660.0 : 426.0;
}
/**
......@@ -584,5 +589,23 @@ public class Prefs implements Serializable
this.preferredLocale = preferredLocale;
}
/**
* Open circuit mode even if segment have setPoint stored it won't be taken in to consideration.
*
* @return the ocMode
*/
public boolean isOcMode() {
return ocMode;
}
/**
* Open circuit mode even if segment have setPoint stored it won't be taken in to consideration.
*
* @param ocMode the ocMode to set
*/
public void setOcMode(boolean ocMode) {
this.ocMode = ocMode;
}
}
......@@ -27,6 +27,7 @@ package mvplan.segments;
import java.io.*;
import mvplan.gas.Gas;
import mvplan.main.MvplanInstance;
import mvplan.prefs.Prefs;
public abstract class SegmentAbstract implements Serializable, Cloneable , Comparable<SegmentAbstract>
{
......@@ -78,16 +79,19 @@ public abstract class SegmentAbstract implements Serializable, Cloneable , Compa
* @return Equivalent Narcosis Depth (END) in msw (fsw)
*/
public double getEnd() {
double pAbsolute = depth + MvplanInstance.getMvplan().getPrefs().getPAmb(); // msw (fsw)
Prefs prefs = MvplanInstance.getMvplan().getPrefs();
double pAbsolute = depth + prefs.getPAmb(); // msw (fsw)
boolean ocMode = prefs.isOcMode();
double fN2 = gas.getFN2();
double fHe = gas.getFHe();
double pInert;
double ppN2Inspired;
// Set inspired gas fractions.
if(setpoint > 0.0) {
if(setpoint > 0.0 && !ocMode) {
// Rebreather mode
// Determine pInert by subtracting absolute oxygen pressure (msw), or force to zero if no inert fraction
pInert = ((fHe+fN2)>0.0) ? pAbsolute - setpoint * MvplanInstance.getMvplan().getPrefs().getPConversion() : 0.0;
pInert = ((fHe+fN2)>0.0) ? pAbsolute - setpoint * prefs.getPConversion() : 0.0;
ppN2Inspired = pInert>0.0 ? (pInert * fN2)/(fHe+fN2) : 0.0;
} else
// Open circuit mode
......
......@@ -26,6 +26,7 @@ package mvplan.segments;
import mvplan.gas.Gas;
import mvplan.main.MvplanInstance;
import mvplan.prefs.Prefs;
public class SegmentAscDec extends SegmentAbstract
{
......@@ -61,7 +62,9 @@ public class SegmentAscDec extends SegmentAbstract
*/
public double gasUsed()
{
if(setpoint>0.0) return(0.0);
Prefs prefs = MvplanInstance.getPrefs();
boolean ocMode = prefs.isOcMode();
if(setpoint>0.0 && !ocMode) return(0.0);
double p; // pressure
double d; // depth
......@@ -70,8 +73,8 @@ public class SegmentAscDec extends SegmentAbstract
startDepth=depth - rate*time;
// Calculate average depth
d=startDepth+(depth-startDepth)/2.0;
p=(d+MvplanInstance.getMvplan().getPrefs().getPAmb())/MvplanInstance.getMvplan().getPrefs().getPConversion(); // Convert to pressure (atm);
return( p * time * MvplanInstance.getMvplan().getPrefs().getDiveRMV());
p=(d+prefs.getPAmb())/prefs.getPConversion(); // Convert to pressure (atm);
return( p * time * prefs.getDiveRMV());
}
/** Gets ascent rate for segment
......
......@@ -26,6 +26,7 @@ package mvplan.segments;
import mvplan.gas.Gas;
import mvplan.main.MvplanInstance;
import mvplan.prefs.Prefs;
/**
* Segment - describes a Deco Segment, a specialisation of AbstractSegment
......@@ -65,11 +66,13 @@ public class SegmentDeco extends SegmentAbstract
* @return Gas Used in litres (cuft)
*/
public double gasUsed()
{
if(setpoint>0.0) return(0.0); // No gas used for closed circuit
{
Prefs prefs = MvplanInstance.getPrefs();
boolean ocMode = prefs.isOcMode();
if(setpoint>0.0 && !ocMode) return(0.0); // No gas used for closed circuit
double p; // pressure
p=(depth+MvplanInstance.getMvplan().getPrefs().getPAmb())/MvplanInstance.getMvplan().getPrefs().getPConversion(); // Convert to pressure (atm);
return( p * time * MvplanInstance.getMvplan().getPrefs().getDecoRMV());
p=(depth+prefs.getPAmb())/prefs.getPConversion(); // Convert to pressure (atm);
return( p * time * prefs.getDecoRMV());
}
......
......@@ -26,6 +26,7 @@ package mvplan.segments;
import mvplan.gas.Gas;
import mvplan.main.MvplanInstance;
import mvplan.prefs.Prefs;
public class SegmentDive extends SegmentAbstract
{
......@@ -59,10 +60,12 @@ public class SegmentDive extends SegmentAbstract
*/
public double gasUsed()
{
if(setpoint>0.0) return(0.0);
Prefs prefs = MvplanInstance.getPrefs();
boolean ocMode = prefs.isOcMode();
if(setpoint>0.0 && !ocMode) return(0.0);
double p; // pressure
p=(depth+MvplanInstance.getMvplan().getPrefs().getPAmb())/MvplanInstance.getMvplan().getPrefs().getPConversion(); // Convert to pressure (atm);
return( p * time * MvplanInstance.getMvplan().getPrefs().getDiveRMV());
p=(depth+prefs.getPAmb())/prefs.getPConversion(); // Convert to pressure (atm);
return( p * time * prefs.getDiveRMV());
}
......
......@@ -291,6 +291,7 @@ mvplan.gui.text.ProfilePrinter.warningPpO2.text = WARNING: Maximum ppO2 on this
mvplan.gui.text.ProfilePrinter.atmCnsEstimate.text = atm. CNS is estimated only.
# Standard output (uses some of the above strings)
mvplan.gui.text.ProfilePrinter.heading.text = Time Run Gas SP
mvplan.gui.text.ProfilePrinter.heading.textNoSP = Time Run Gas
# Altitude messages
mvplan.gui.text.altitude.text = Altitude:
mvplan.gui.text.altitudeCalibration.text = calibrated depth.
......
......@@ -291,6 +291,7 @@ mvplan.gui.text.ProfilePrinter.warningPpO2.text = ATTENTION : La PpO2 maximale d
mvplan.gui.text.ProfilePrinter.atmCnsEstimate.text = bar. La toxicit\u00E9 SNC est donn\u00E9e \u00E0 titre indicatif.
# Standard output (uses some of the above strings)
mvplan.gui.text.ProfilePrinter.heading.text = Dur\u00E9e Total Gaz SP
mvplan.gui.text.ProfilePrinter.heading.textNoSP = Dur\u00E9e Total Gaz
# Altitude messages
mvplan.gui.text.altitude.text = Altitude :
mvplan.gui.text.altitudeCalibration.text = profondeur calibr\u00E9e
......
......@@ -291,6 +291,7 @@ mvplan.gui.text.ProfilePrinter.warningPpO2.text = ATTENZIONE: La ppO2 massima in
mvplan.gui.text.ProfilePrinter.atmCnsEstimate.text = atm. CNS e' solo stimato.
# Standard output (uses some of the above strings)
mvplan.gui.text.ProfilePrinter.heading.text = Tempo Run Gas SP
mvplan.gui.text.ProfilePrinter.heading.textNoSP = Tempo Run Gas
# Altitude messages
mvplan.gui.text.altitude.text = Altitudine:
mvplan.gui.text.altitudeCalibration.text = profondita' calibrata.
......
......@@ -277,6 +277,7 @@ mvplan.gui.text.ProfilePrinter.atmCnsEstimate.text = atm. A toxicidade ao SNC \u
# Standard output (uses some of the above strings)
mvplan.gui.text.ProfilePrinter.heading.text = Tempo Corrido G\u00E1s SP
mvplan.gui.text.ProfilePrinter.heading.textNoSP =Tempo Corrido G\u00E1s
# Altitude messages
mvplan.gui.text.altitude.text = Altitude:
......
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