Dear NS Users, I am trying to add a new Agent in ns-2.35. however it gave me an error Invalid Command Name. Then I tried the same code in ns-2.34 and it works all right. Are there any changes in the mechanism of adding Agent in ns-2.35...
I have been doing the following: I modified the Makefile , OBJ_CC variable and add the corresponding object of the code. The C++ Code and the TCL scripts I tried are as follows: ################################################## C++ ################################### #include <stdio.h> #include <string.h> #include "agent.h" class MyAgent : public Agent { public: MyAgent(); protected: int command(int argc, const char*const* argv); private: int my_var1; double my_var2; void MyPrivFunc(void); }; static class MyAgentClass : public TclClass { public: MyAgentClass() : TclClass("Agent/MyAgentOtcl") {} TclObject* create(int, const char*const*) { return(new MyAgent()); } } class_my_agent; MyAgent::MyAgent() : Agent(PT_UDP) { bind("my_var1_otcl", &my_var1); bind("my_var2_otcl", &my_var2); }int MyAgent::command(int argc, const char*const* argv) { if(argc == 2) { if(strcmp(argv[1], "call-my-priv-func") == 0) { MyPrivFunc(); return(TCL_OK); } } return(Agent::command(argc, argv)); } void MyAgent::MyPrivFunc(void) { Tcl& tcl = Tcl::instance(); tcl.eval("puts \"Message From MyPrivFunc\""); tcl.evalf("puts \" my_var1 = %d\"", my_var1); tcl.evalf("puts \" my_var2 = %f\"", my_var2); } ################################################## C++ ################################### The corresponding tcl script is ################################################## TCL ################################### # Create MyAgent (This will give two warning messages that # no default vaules exist for my_var1_otcl and my_var2_otcl) set myagent [new Agent/MyAgentOtcl] # Set configurable parameters of MyAgent $myagent set my_var1_otcl 2 $myagent set my_var2_otcl 3.14 # Give a command to MyAgent $myagent call-my-priv-func ################################################## TCL ################################### In ns-2.34 this code runs all right... while in ns-2.35 it throws me following error : invalid command name "Agent/MyAgentOtcl" while executing "Agent/MyAgentOtcl create _o3 " invoked from within "catch "$className create $o $args" msg" invoked from within "if [catch "$className create $o $args" msg] { if [string match "__FAILED_SHADOW_OBJECT_" $msg] { delete $o return "" } global errorInfo error "class $..." (procedure "new" line 3) invoked from within "new Agent/MyAgentOtcl" invoked from within "set myagent [new Agent/MyAgentOtcl]" (file "a.tcl" line 5) I will be very thankful for any help in this regard..... Regards, sam