2 * Copyright © 2015 ZTE 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
8 package com.highstreet.technologies.odl.app.impl.tools;
10 import org.slf4j.Logger;
11 import org.slf4j.LoggerFactory;
13 import java.text.DecimalFormat;
15 import static com.google.common.math.DoubleMath.log2;
18 * Created by odl on 17-6-8.
20 public class BandwidthCalculator
22 private static final Logger LOG = LoggerFactory.getLogger(BandwidthCalculator.class);
24 public BandwidthCalculator(Integer txChannelBandwidth, Short modulationCur, Byte codeRateCur)
26 LOG.info("bandwidth: " + txChannelBandwidth + " modulationCur: " + modulationCur + " codeRate: " + codeRateCur);
27 this.result = txChannelBandwidth * log2(modulationCur) * (0.8) / 1.15;
30 private static DecimalFormat df = new DecimalFormat("#.00");
31 private final double result;
33 public Double calc(Unit unit)
35 return Double.valueOf(df.format(unit.convert(result, Unit.k_bits_s)));
40 return Double.valueOf(df.format(result));