2 * Copyright © 2017 Orange, Inc. and others. All rights reserved.
4 * This program and the accompanying materials are made available under the
5 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6 * and is available at http://www.eclipse.org/legal/epl-v10.html
9 package org.opendaylight.transportpce.common.fixedflex;
11 public final class FixedFlexImpl implements FixedFlexInterface {
13 private double centerFrequency;
16 private double wavelength;
17 // wavelengthSpacing is in GHz
18 float wavelengthSpacing = 50;
19 // beginWavelength is in nm: f or F is appended to treat it explicitly as simple float (and not double float)
20 final float beginWavelength = 1528.77f;
21 // java double is double float - d or D is appended to treat it explicitly as double float
22 final double precision = 10000d;
24 public FixedFlexImpl(Long index, double centreFrequency, double start, double stop, double wavelength) {
26 this.centerFrequency = centreFrequency;
29 this.wavelength = wavelength;
32 public FixedFlexImpl() {
34 this.centerFrequency = 0;
40 public FixedFlexImpl(long wlIndex) {
41 this.centerFrequency = 196.1 - (wlIndex - 1) * wavelengthSpacing / 1000;
42 // Truncate the value to the two decimal places
43 this.centerFrequency = Math.round(this.centerFrequency * precision) / precision;
44 this.start = this.centerFrequency - (wavelengthSpacing / 2) / 1000;
45 this.start = Math.round(this.start * precision) / precision;
46 this.stop = this.centerFrequency + (wavelengthSpacing / 2) / 1000;
47 this.stop = Math.round(this.stop * precision) / precision;
48 this.wavelength = beginWavelength + ((wlIndex - 1) * 0.40);
49 this.wavelength = Math.round(this.wavelength * precision) / precision;
54 * @param index Wavelength number
55 * @return Returns FixedFlexImp object with the calculated result.
57 public FixedFlexImpl getFixedFlexWaveMapping(long wlIndex) {
58 // In Flex grid -35 <= n <= 60
59 long mappedWL = 61 - wlIndex;
60 FixedFlexImpl fixedFlex = new FixedFlexImpl();
61 fixedFlex.centerFrequency = 193.1 + (50.0 / 1000.0) * mappedWL;
62 fixedFlex.centerFrequency = Math.round(fixedFlex.centerFrequency * precision) / precision;
63 fixedFlex.wavelength = beginWavelength + ((wlIndex - 1) * 0.40);
64 fixedFlex.wavelength = Math.round(fixedFlex.wavelength * precision) / precision;
65 fixedFlex.start = 193.1 + (50.0 * mappedWL - 25) / 1000.0;
66 fixedFlex.start = Math.round(fixedFlex.start * precision) / precision;
67 fixedFlex.stop = 193.1 + (50.0 * mappedWL + 25) / 1000.0;
68 fixedFlex.stop = Math.round(fixedFlex.stop * precision) / precision;
69 fixedFlex.index = wlIndex;
73 public double getCenterFrequency() {
74 return centerFrequency;
77 public double getStart() {
81 public long getIndex() {
85 public double getStop() {
89 public double getWavelength() {