Main Page | Namespace List | Class Hierarchy | Alphabetical List | Compound List | File List | Compound Members | File Members

adc.cc

Go to the documentation of this file.
00001 /* -*-  Mode:C++; c-basic-offset:8; tab-width:8; indent-tabs-mode:t -*- */
00002 /*
00003  * Copyright (c) Xerox Corporation 1997. All rights reserved.
00004  *
00005  * License is granted to copy, to use, and to make and to use derivative
00006  * works for research and evaluation purposes, provided that Xerox is
00007  * acknowledged in all documentation pertaining to any such copy or
00008  * derivative work. Xerox grants no other licenses expressed or
00009  * implied. The Xerox trade name should not be used in any advertising
00010  * without its written permission. 
00011  *
00012  * XEROX CORPORATION MAKES NO REPRESENTATIONS CONCERNING EITHER THE
00013  * MERCHANTABILITY OF THIS SOFTWARE OR THE SUITABILITY OF THIS SOFTWARE
00014  * FOR ANY PARTICULAR PURPOSE.  The software is provided "as is" without
00015  * express or implied warranty of any kind.
00016  *
00017  * These notices must be retained in any copies of any part of this
00018  * software. 
00019  */
00020 #ifndef lint
00021 static const char rcsid[] =
00022         "@(#) $Header: /nfs/jade/vint/CVSROOT/ns-2/adc/adc.cc,v 1.7 1999/02/12 22:01:31 breslau Exp $";
00023 #endif
00024 
00025 #include "adc.h"
00026 #include <stdlib.h>
00027 
00028 ADC::ADC() :bandwidth_(0), tchan_(0)
00029 {
00030         bind_bw("bandwidth_",&bandwidth_);
00031         bind_bool("backoff_",&backoff_);
00032         bind("src_", &src_);
00033         bind("dst_", &dst_);
00034         bind_bool("dobump_", &dobump_);
00035 }
00036 
00037 int ADC::command(int argc,const char*const*argv)
00038 {
00039         
00040         Tcl& tcl = Tcl::instance();
00041         if (argc==2) {
00042                 if (strcmp(argv[1],"start") ==0) {
00043                         /* $adc start */
00044                         est_[1]->start();
00045                         return (TCL_OK);
00046                 }
00047         } else if (argc==4) {
00048                 if (strcmp(argv[1],"attach-measmod") == 0) {
00049                         /* $adc attach-measmod $meas $cl */
00050                         MeasureMod *meas_mod = (MeasureMod *)TclObject::lookup(argv[2]);
00051                         if (meas_mod== 0) {
00052                                 tcl.resultf("no measuremod found");
00053                                 return(TCL_ERROR);
00054                         }
00055                         int cl=atoi(argv[3]);
00056                         est_[cl]->setmeasmod(meas_mod);
00057                         return(TCL_OK);
00058                 } else if (strcmp(argv[1],"attach-est") == 0 ) {
00059                         /* $adc attach-est $est $cl */
00060                         Estimator *est_mod = (Estimator *)TclObject::lookup(argv[2]);
00061                         if (est_mod== 0) {
00062                                 tcl.resultf("no estmod found");
00063                                 return(TCL_ERROR);
00064                         }
00065                         int cl=atoi(argv[3]);
00066                         setest(cl,est_mod);
00067                         return(TCL_OK);
00068                 }
00069         }
00070         else if (argc == 3) {
00071                 if (strcmp(argv[1], "attach") == 0) {
00072                         int mode;
00073                         const char* id = argv[2];
00074                         tchan_ = Tcl_GetChannel(tcl.interp(), (char*)id, &mode);
00075                         if (tchan_ == 0) {
00076                                 tcl.resultf("ADC: trace: can't attach %s for writing", id);
00077                                 return (TCL_ERROR);
00078                         }
00079                         return (TCL_OK);
00080                         
00081                 }
00082                 if (strcmp(argv[1], "setbuf") == 0) {
00083                         /* some sub classes actually do something here */
00084                         return(TCL_OK);
00085                 }
00086 
00087 
00088         }
00089         return (NsObject::command(argc,argv));
00090 }
00091 
00092 
00093 
00094 

Generated on Tue Apr 20 12:14:10 2004 for NS2.26SourcesOriginal by doxygen 1.3.3