Enabled flex-grid support for 2.2.1 Roadms
[transportpce.git] / common / src / main / java / org / opendaylight / transportpce / common / fixedflex / FlexGridImpl.java
1 /*
2  * Copyright © 2020 AT&T, 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 class FlexGridImpl implements FlexGridInterface {
12     private double start;
13     private double stop;
14     static final double PRECISION = 100000d;
15
16     public FlexGridImpl(double start, double stop) {
17         this.start = start;
18         this.stop = stop;
19     }
20
21     public FlexGridImpl() {
22         this.start = 0;
23         this.stop = 0;
24     }
25
26     @Override
27     public FlexGridImpl getFlexWaveMapping(float centerFrequency, float slotwidth) {
28         FlexGridImpl flexGridImpl = new FlexGridImpl();
29         flexGridImpl.start = centerFrequency - (slotwidth / 2) / 1000.0;
30         flexGridImpl.start = Math.round(flexGridImpl.start * PRECISION) / PRECISION;
31         flexGridImpl.stop = centerFrequency + (slotwidth / 2) / 1000.0;
32         flexGridImpl.stop = Math.round(flexGridImpl.stop * PRECISION) / PRECISION;
33         return flexGridImpl;
34     }
35
36     public double getStart() {
37         return start;
38     }
39
40     public double getStop() {
41         return stop;
42     }
43 }
44