71f9f04c2376e0e2b755c4a8ad0c58d19828e8ef
[transportpce.git] / common / src / main / java / org / opendaylight / transportpce / common / fixedflex / FixedFlexImpl.java
1 /*
2  * Copyright © 2017 Orange, Inc. and others.  All rights reserved.
3  *
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
7  */
8
9 package org.opendaylight.transportpce.common.fixedflex;
10
11 public final class FixedFlexImpl implements FixedFlexInterface {
12     private long index;
13     private double centerFrequency;
14     private double start;
15     private double stop;
16     private double wavelength;
17
18     public FixedFlexImpl(Long index, double centreFrequency, double start, double stop, double wavelength) {
19         this.index = index;
20         this.centerFrequency = centreFrequency;
21         this.start = start;
22         this.stop = stop;
23         this.wavelength = wavelength;
24     }
25
26     public FixedFlexImpl() {
27         this.index = 0L;
28         this.centerFrequency = 0;
29         this.start = 0;
30         this.stop = 0;
31         this.wavelength = 0;
32     }
33
34     public FixedFlexImpl(long wlIndex) {
35         this.index = wlIndex;
36         this.centerFrequency = 196.1 - (wlIndex - 1) * 0.05;
37         this.start = this.centerFrequency - 0.025;
38         this.stop = this.centerFrequency + 0.025;
39         this.wavelength = 1528.77 + ((wlIndex - 1) * 0.39);
40     }
41
42     @Override
43     /**
44      * @param index Wavelength number
45      * @return Returns FixedFlexImp object with the calculated result.
46      **/
47     public FixedFlexImpl getFixedFlexWaveMapping(long wlIndex) {
48         FixedFlexImpl fixedFlex = new FixedFlexImpl();
49         long mappedWL = wlIndex - 36;
50         fixedFlex.centerFrequency = 193.1 + (50.0 / 1000.0) * mappedWL;
51         fixedFlex.start = 193.1 + (50.0 * mappedWL - 25) / 1000.0;
52         fixedFlex.stop = 193.1 + (50.0 * mappedWL + 25) / 1000.0;
53         return fixedFlex;
54     }
55
56     public double getCenterFrequency() {
57         return centerFrequency;
58     }
59
60     public double getStart() {
61         return start;
62     }
63
64     public long getIndex() {
65         return index;
66     }
67
68     public double getStop() {
69         return stop;
70     }
71
72     public double getWavelength() {
73         return wavelength;
74     }
75 }