-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSegmentDeco.java
More file actions
106 lines (95 loc) · 3.73 KB
/
SegmentDeco.java
File metadata and controls
106 lines (95 loc) · 3.73 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
/*
* SegmentDeco.java
*
* Describes a Deco Segment, a specialisation of AbstractSegment
*
* @author Guy Wittig
* @version 18-Jun-2006
*
* This program is part of MV-Plan
* Copywrite 2006 Guy Wittig
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* The GNU General Public License can be read at http://www.gnu.org/licenses/licenses.html
*/
package mvplan.segments;
import mvplan.main.Mvplan;
import java.text.MessageFormat;
import mvplan.gas.Gas;
import mvplan.prefs.Prefs;
/**
* Segment - describes a Deco Segment, a specialisation of AbstractSegment
*
* @author Guy Wittig
* @version 17-Dec-2005
*/
public class SegmentDeco extends SegmentAbstract
{
/** Maximum M-Value Gradient encountered in this segment */
private double mvMax;
/** Gradient Factor used in this segment */
private double gfUsed;
/** Controlling compartment of this segment */
private int controlCompartment;
/** Constructor for objects of class SegmentDeco
* @param depth Depth of segment
* @param time Time of segment
* @param gas Gas object for segment
* @param setpoint Setpoint for segment, or 0.0 for open circuit
*/
public SegmentDeco(double depth, double time, Gas gas, double setpoint )
{
super();
super.depth=depth;
super.gas=gas;
super.setpoint=setpoint;
super.type=super.DECO;
super.time=time;
mvMax=0;
gfUsed=0;
controlCompartment=-1;
}
/** Override gasUsed() to determine the gas used in this segment
* @return Gas Used in litres (cuft)
*/
public double gasUsed()
{
if(setpoint>0.0) return(0.0); // No gas used for closed circuit
double p; // pressure
p=(depth+Prefs.getPrefs().getPAmb())/Prefs.getPrefs().getPConversion(); // Convert to pressure (atm);
return( p * time * Prefs.getPrefs().getDecoRMV());
}
/** Override toString to return String representation of DecoSegment
* @return String representation of DecoSegment
*/
public String toStringLong()
{
int timeMins,timeSeconds;
timeMins=(int)time;
timeSeconds = (int)((time - (double)timeMins)*60.0);
return String.format("DECO:%1$3.0f"+Prefs.getPrefs().getDepthShortString()+" for %2$02d:%3$02d [%4$3.0f] on %5$s, SP: %6$3.1f, END:%7$3.0f"+Prefs.getPrefs().getDepthShortString()+" M-Value: %8$02.0f%% [%9$02d], GF: %10$02.0f%%",
depth, timeMins, timeSeconds, runTime, gas.toString(), setpoint, getEnd(), mvMax*100, controlCompartment, gfUsed*100);
}
/**************** Accessor and mutator methods ****************/
/** Sets controlling compartment - required for Bean interface
* @param c Compartment number
*/
public void setControlCompartment(int c) {controlCompartment=c;}
/** Sets Gradient factor used - required for Bean Interface
* @param gf GradientFactor used
*/
public void setGfUsed(double gf) {gfUsed=gf;}
/** Sets Maximum M-Value Gradient for compartment - required for Bean interface
* @param mv M-Value Gradient
*/
public void setMvMax(double mv) {mvMax=mv;}
}