<filename>project/c++/mri/src/common/src/counter/kpicounter/link_byte.cc
// Copyright (2013) <NAME>.  All rights reserved.

#include "xtreme/common/counter/kpicounter/link_byte.h"

namespace xtreme {

void LinkByte::ComputeMeasurement(
    FrameEvent& event, uint64_t bin,
    const aggregator::EnginesInterface& interface) {
  // Subtract the number of bins that are already consolidated.
  if (bin >= num_of_bins_consolidated_) {
    bin -= num_of_bins_consolidated_;
  }

  // bin 0 is the first bin, so we need to expand to (bin+1) number of bins, if necessary.
  if (bin_.size() <= bin) {
    bin_.resize(bin + 1, kDirectionalBin);
  }

  bin_[bin][DIRECTION_BOTH] += event.original_length();
  if (xtreme::DIRECTION_UPLINK == event.parsed_frame()->direction_) {
    bin_[bin][DIRECTION_UPLINK] += event.original_length();
  } else if (xtreme::DIRECTION_DOWNLINK == event.parsed_frame()->direction_) {
    bin_[bin][DIRECTION_DOWNLINK] += event.original_length();
  }
}

void LinkByte::Merge(KpiCounter *counter) {
  MergeTimeBased_Directional(counter);
}
}
