X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=common%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Ftransportpce%2Fcommon%2Ffixedflex%2FFixedFlexImpl.java;h=0059747ea7947400d49883dc3b8b9b3f61f2d27a;hb=refs%2Fchanges%2F75%2F87675%2F8;hp=9b4e3b1457e1e6166cc70c51548bb6a8b6de964b;hpb=f5b5168d02112acea744f61b72ba3ab273f1a215;p=transportpce.git diff --git a/common/src/main/java/org/opendaylight/transportpce/common/fixedflex/FixedFlexImpl.java b/common/src/main/java/org/opendaylight/transportpce/common/fixedflex/FixedFlexImpl.java index 9b4e3b145..0059747ea 100644 --- a/common/src/main/java/org/opendaylight/transportpce/common/fixedflex/FixedFlexImpl.java +++ b/common/src/main/java/org/opendaylight/transportpce/common/fixedflex/FixedFlexImpl.java @@ -16,10 +16,10 @@ public final class FixedFlexImpl implements FixedFlexInterface { 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; @@ -40,13 +40,13 @@ public final class FixedFlexImpl implements FixedFlexInterface { 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 @@ -59,13 +59,13 @@ public final class FixedFlexImpl implements FixedFlexInterface { 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; }