//  
//  Copyright (c) 1994 by Mike Romberg (  romberg@md.fsl.noaa.gov )
//  Debugged and Featurized by Michael Hemy
//
//  This file may be distributed under terms of the GPL
//

#include "netoutmeter.h"
#include <math.h>
#include <stdio.h>

NetOutMeter::NetOutMeter(XOSView *parent, int x, int y, 
			 int width, int height, float max )
: FieldMeter( parent, x, y, width, height, 2, "OUT", "PACKETS/SEC IDLE" ){
  maxpackets_ = max;
}

NetOutMeter::~NetOutMeter( void ){
}

void NetOutMeter::checkevent( void ){
  total_ = 1000;
  double dtmp1, dtmp2, dtmp3;
  extra_val_ = outgoing();
  dtmp1 = double(extra_val_) / double(maxpackets_);
  dtmp2 = pow(2.0, -dtmp1);
  dtmp3 = 1000*(1.0 -dtmp2); 
  fields_[0] = int(dtmp3);
  fields_[1] = total_ - fields_[0];
  sprintf(extra_str_,"%4d%", int(extra_val_>9999.0 ? 9999 : extra_val_));
  drawfields();
}
