private double wavelength;
// wavelengthSpacing is in GHz
float wavelengthSpacing = 50;
- // beginWavelength is in nm: f or F is appended to treat it explicitly as simple float (and not double float)
- final float beginWavelength = 1528.77f;
+ // BEGIN_WAVELENGTH is in nm: f or F is appended to treat it explicitly as simple float (and not double float)
+ static final float BEGIN_WAVELENGTH = 1528.77f;
// java double is double float - d or D is appended to treat it explicitly as double float
- final double precision = 10000d;
+ static final double PRECISION = 10000d;
public FixedFlexImpl(Long index, double centreFrequency, double start, double stop, double wavelength) {
this.index = index;
public FixedFlexImpl(long wlIndex) {
this.centerFrequency = 196.1 - (wlIndex - 1) * wavelengthSpacing / 1000;
// Truncate the value to the two decimal places
- this.centerFrequency = Math.round(this.centerFrequency * precision) / precision;
+ this.centerFrequency = Math.round(this.centerFrequency * PRECISION) / PRECISION;
this.start = this.centerFrequency - (wavelengthSpacing / 2) / 1000;
- this.start = Math.round(this.start * precision) / precision;
+ this.start = Math.round(this.start * PRECISION) / PRECISION;
this.stop = this.centerFrequency + (wavelengthSpacing / 2) / 1000;
- this.stop = Math.round(this.stop * precision) / precision;
- this.wavelength = beginWavelength + ((wlIndex - 1) * 0.40);
- this.wavelength = Math.round(this.wavelength * precision) / precision;
+ this.stop = Math.round(this.stop * PRECISION) / PRECISION;
+ this.wavelength = BEGIN_WAVELENGTH + ((wlIndex - 1) * 0.40);
+ this.wavelength = Math.round(this.wavelength * PRECISION) / PRECISION;
}
@Override
long mappedWL = 61 - wlIndex;
FixedFlexImpl fixedFlex = new FixedFlexImpl();
fixedFlex.centerFrequency = 193.1 + (50.0 / 1000.0) * mappedWL;
- fixedFlex.centerFrequency = Math.round(fixedFlex.centerFrequency * precision) / precision;
- fixedFlex.wavelength = beginWavelength + ((wlIndex - 1) * 0.40);
- fixedFlex.wavelength = Math.round(fixedFlex.wavelength * precision) / precision;
+ fixedFlex.centerFrequency = Math.round(fixedFlex.centerFrequency * PRECISION) / PRECISION;
+ fixedFlex.wavelength = BEGIN_WAVELENGTH + ((wlIndex - 1) * 0.40);
+ fixedFlex.wavelength = Math.round(fixedFlex.wavelength * PRECISION) / PRECISION;
fixedFlex.start = 193.1 + (50.0 * mappedWL - 25) / 1000.0;
- fixedFlex.start = Math.round(fixedFlex.start * precision) / precision;
+ fixedFlex.start = Math.round(fixedFlex.start * PRECISION) / PRECISION;
fixedFlex.stop = 193.1 + (50.0 * mappedWL + 25) / 1000.0;
- fixedFlex.stop = Math.round(fixedFlex.stop * precision) / precision;
+ fixedFlex.stop = Math.round(fixedFlex.stop * PRECISION) / PRECISION;
fixedFlex.index = wlIndex;
return fixedFlex;
}