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 * This program is free software; you can redistribute it and/or modify it 00006 * under the terms of the GNU General Public License as published by the 00007 * Free Software Foundation; either version 2 of the License, or (at your 00008 * option) any later version. 00009 * 00010 * This program is distributed in the hope that it will be useful, but 00011 * WITHOUT ANY WARRANTY; without even the implied warranty of 00012 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00013 * General Public License for more details. 00014 * 00015 * You should have received a copy of the GNU General Public License along 00016 * with this program; if not, write to the Free Software Foundation, Inc., 00017 * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 00018 * 00019 * Linking this file statically or dynamically with other modules is making 00020 * a combined work based on this file. Thus, the terms and conditions of 00021 * the GNU General Public License cover the whole combination. 00022 * 00023 * In addition, as a special exception, the copyright holders of this file 00024 * give you permission to combine this file with free software programs or 00025 * libraries that are released under the GNU LGPL and with code included in 00026 * the standard release of ns-2 under the Apache 2.0 license or under 00027 * otherwise-compatible licenses with advertising requirements (or modified 00028 * versions of such code, with unchanged license). You may copy and 00029 * distribute such a system following the terms of the GNU GPL for this 00030 * file and the licenses of the other code concerned, provided that you 00031 * include the source code of that other code when and as the GNU GPL 00032 * requires distribution of source code. 00033 * 00034 * Note that people who make modified versions of this file are not 00035 * obligated to grant this special exception for their modified versions; 00036 * it is their choice whether to do so. The GNU General Public License 00037 * gives permission to release a modified version without this exception; 00038 * this exception also makes it possible to release a modified version 00039 * which carries forward this exception. 00040 */ 00041 #ifndef lint 00042 static const char rcsid[] = 00043 "@(#) $Header: /nfs/jade/vint/CVSROOT/ns-2/adc/adc.cc,v 1.8 2005/08/26 05:05:27 tomh Exp $"; 00044 #endif 00045 00046 #include "adc.h" 00047 #include <stdlib.h> 00048 00049 ADC::ADC() :bandwidth_(0), tchan_(0) 00050 { 00051 bind_bw("bandwidth_",&bandwidth_); 00052 bind_bool("backoff_",&backoff_); 00053 bind("src_", &src_); 00054 bind("dst_", &dst_); 00055 bind_bool("dobump_", &dobump_); 00056 } 00057 00058 int ADC::command(int argc,const char*const*argv) 00059 { 00060 00061 Tcl& tcl = Tcl::instance(); 00062 if (argc==2) { 00063 if (strcmp(argv[1],"start") ==0) { 00064 /* $adc start */ 00065 est_[1]->start(); 00066 return (TCL_OK); 00067 } 00068 } else if (argc==4) { 00069 if (strcmp(argv[1],"attach-measmod") == 0) { 00070 /* $adc attach-measmod $meas $cl */ 00071 MeasureMod *meas_mod = (MeasureMod *)TclObject::lookup(argv[2]); 00072 if (meas_mod== 0) { 00073 tcl.resultf("no measuremod found"); 00074 return(TCL_ERROR); 00075 } 00076 int cl=atoi(argv[3]); 00077 est_[cl]->setmeasmod(meas_mod); 00078 return(TCL_OK); 00079 } else if (strcmp(argv[1],"attach-est") == 0 ) { 00080 /* $adc attach-est $est $cl */ 00081 Estimator *est_mod = (Estimator *)TclObject::lookup(argv[2]); 00082 if (est_mod== 0) { 00083 tcl.resultf("no estmod found"); 00084 return(TCL_ERROR); 00085 } 00086 int cl=atoi(argv[3]); 00087 setest(cl,est_mod); 00088 return(TCL_OK); 00089 } 00090 } 00091 else if (argc == 3) { 00092 if (strcmp(argv[1], "attach") == 0) { 00093 int mode; 00094 const char* id = argv[2]; 00095 tchan_ = Tcl_GetChannel(tcl.interp(), (char*)id, &mode); 00096 if (tchan_ == 0) { 00097 tcl.resultf("ADC: trace: can't attach %s for writing", id); 00098 return (TCL_ERROR); 00099 } 00100 return (TCL_OK); 00101 00102 } 00103 if (strcmp(argv[1], "setbuf") == 0) { 00104 /* some sub classes actually do something here */ 00105 return(TCL_OK); 00106 } 00107 00108 00109 } 00110 return (NsObject::command(argc,argv)); 00111 } 00112 00113 00114 00115
1.4.6