package org.vrjuggler.perfmon;

import javax.swing.*;
import java.lang.reflect.*;
import org.jfree.data.time.*;
import vrj.PerformanceMonitorSubjectPackage.SampleTimeMap;
import vrj.*;

public class Updater implements Runnable
{
  TimeSeriesCollection mTimeSeriesCollection;
  double mLastValue = 100.0;
  SpinnerModel mSpinnerModel = null;
  private PerformanceMonitorObserverImpl mObserver;


  public Updater ( TimeSeriesCollection series, SpinnerModel model, 
                   PerformanceMonitorObserverImpl observer )
  {
     //Will get multiple time series based on the list that comes back
     //from c++ side
    mTimeSeriesCollection = series;
    mSpinnerModel = model;
    mObserver = observer;
    try 
    {
      /*
       *
      // create and initialize the ORB
      ORB mOrb = ORB.init();

      // get the root naming context
      org.omg.CORBA.Object mObjRef =
        mOrb.resolve_initial_references("Performance Monitor");

      // Use NamingContextExt instead of NamingContext. This is
      // part of the Interoperable Naming Service.
      NamingContextExt mRef =
        NamingContextExtHelper.narrow(mObjRef);
       */
    }
    catch (Exception e) 
    {
       System.out.println("ERROR : " + e) ;
       e.printStackTrace(System.out);
    }

  }

  public void run ()
  {
     if(mObserver == null)
     { System.out.println("[DBG] mObserver is null!!!!!"); }
    SampleTimeMap[] value_map = mObserver.getValueMap();
    int length = Array.getLength(value_map);
    System.out.println("[DBG] Got a samples list of length " + length);
    for (int i = 0; i < length; ++i)
    {
      System.out.println("[DBG] Adding a new series for " + value_map[i].mName);
      TimeSeries s = new TimeSeries(value_map[i].mName, Millisecond.class);
      mTimeSeriesCollection.addSeries(s);
    }
    while ( true )
    {
      try
      {
        Thread.sleep( ( ( Integer ) mSpinnerModel.getValue() ).longValue() );
      }
      catch ( InterruptedException ex )
      {
        ex.printStackTrace();
      }

      value_map = mObserver.getValueMap();
      length = Array.getLength(value_map);
      for (int i = 0; i < length; ++i)
      {
         mTimeSeriesCollection.getSeries(i).add( new Millisecond(), value_map[i].mSampleTime );
         //System.out.println("[DBG] Setting value for series " + i);
      }
      
      Thread.yield();
    }
  }
}

@@ -1,8 +1,1347 @@
+/*************** %3Cauto-copyright.pl BEGIN do not edit this line%3E **************%0A *%0A * VR Juggler is (C) Copyright 1998-2003 by Iowa State University%0A *%0A * Original Authors:%0A *   Allen Bierbaum, Christopher Just,%0A *   Patrick Hartling, Kevin Meinert,%0A *   Carolina Cruz-Neira, Albert Baker%0A *%0A * This library is free software; you can redistribute it and/or%0A * modify it under the terms of the GNU Library General Public%0A * License as published by the Free Software Foundation; either%0A * version 2 of the License, or (at your option) any later version.%0A *%0A * This library is distributed in the hope that it will be useful,%0A * but WITHOUT ANY WARRANTY; without even the implied warranty of%0A * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU%0A * Library General Public License for more details.%0A *%0A * You should have received a copy of the GNU Library General Public%0A * License along with this library; if not, write to the%0A * Free Software Foundation, Inc., 59 Temple Place - Suite 330,%0A * Boston, MA 02111-1307, USA.%0A *%0A * -----------------------------------------------------------------%0A * File:          $RCSfile$%0A * Date modified: $Date$%0A * Version:       $Revision$%0A * -----------------------------------------------------------------%0A *%0A *************** %3Cauto-copyright.pl END do not edit this line%3E ***************/%0A
 package 

Add copyright