suptcl.cc

00001 static char code[] = "\n\
00002 ConnectorTrace set depth_ 0\n\
00003 ConnectorTrace set debug_ 0\n\
00004 \n\
00005 \n\
00006 NodeCore set X_ 0\n\
00007 NodeCore set Y_ 0\n\
00008 NodeCore set battery_ 0\n\
00009 \n\
00010 \n\
00011 ConnectorTrace/Bin set depth 10\n\
00012 ConnectorTrace/Bin set depthUp_ 10\n\
00013 ConnectorTrace/Bin set depthDown_ 10\n\
00014 ConnectorTrace/Bin set depthToNC_ 10\n\
00015 ConnectorTrace/Bin set depthToP_ 10\n\
00016 \n\
00017 ConnectorTrace/SAP set depthUp_ 0\n\
00018 ConnectorTrace/SAP set depthDown_ 0\n\
00019 \n\
00020 ConnectorTrace/ChSAP set depthUp_ 0\n\
00021 ConnectorTrace/ChSAP set depthDown_ 0\n\
00022 \n\
00023 ConnectorTrace/ClSAP set depthToP_ 0\n\
00024 ConnectorTrace/ClSAP set depthToNC_ 0\n\
00025 \n\
00026 \n\
00027 \n\
00028 Class M_Node\n\
00029 \n\
00030 M_Node set nLayer_ 0\n\
00031 M_Node set nSap_ 0\n\
00032 M_Node set nChSap_ 0\n\
00033 \n\
00034 M_Node set id_ 0\n\
00035 M_Node set nPlugin_ 0\n\
00036 \n\
00037 M_Node instproc init args {\n\
00038 $self instvar id_ \n\
00039 $self instvar nPlugin_\n\
00040 \n\
00041 $self set id_ 0\n\
00042 $self set nPlugin_ 0\n\
00043 $self set position_ \"\"\n\
00044 }\n\
00045 \n\
00046 \n\
00047 M_Node instproc addModule {layer module param1 {param2 \"\"} {param3 \"\"}} {\n\
00048 $self instvar nPlugin_ bin_ nodeCore_ traceCLfd_ modules_ layer_ id_\n\
00049 \n\
00050 if {$layer < 1} {\n\
00051 puts \" addModule: invalid value ($layer) for layer, must be >=1\"\n\
00052 exit 1\n\
00053 }\n\
00054 \n\
00055 $module Id_ $nPlugin_\n\
00056 $module setlayer $layer\n\
00057 \n\
00058 set clsap [new ConnectorTrace/ClSAP]\n\
00059 $module addBin $bin_\n\
00060 $module addclsap $clsap\n\
00061 \n\
00062 set clDepthP 0\n\
00063 set clDepthNC 0\n\
00064 set moduleName \"\"\n\
00065 if {$param3 == \"\"} {\n\
00066 set clDepthP $param1\n\
00067 set clDepthNC $param1\n\
00068 set moduleName $param2\n\
00069 } else {\n\
00070 set clDepthP $param1\n\
00071 set clDepthNC $param2\n\
00072 set moduleName $param3\n\
00073 }\n\
00074 if {$moduleName != \"\"} {\n\
00075 $module settag \"$moduleName\"\n\
00076 } elseif {[$module gettag] == \"---\"} {\n\
00077 $module settag \"$nPlugin_\"\n\
00078 }\n\
00079 \n\
00080 \n\
00081 $clsap set depthToP_ $clDepthP\n\
00082 $clsap set depthToNC_ $clDepthNC\n\
00083 $clsap module $module\n\
00084 $clsap nodecore $nodeCore_\n\
00085 $clsap preambleToPlugin \"$id_ NC [$module gettag]\"\n\
00086 $clsap preambleToNodeCore \"$id_ [$module gettag] NC\" \n\
00087 $clsap attach $traceCLfd_\n\
00088 $nodeCore_ addclsap $clsap $layer\n\
00089 \n\
00090 set modules_($nPlugin_) $module\n\
00091 set layer_($nPlugin_) $layer\n\
00092 \n\
00093 incr nPlugin_\n\
00094 }\n\
00095 \n\
00096 M_Node instproc addPlugin {plugin param1 {param2 \"\"} {param3 \"\"}} {\n\
00097 $self instvar nPlugin_ bin_ nodeCore_ traceCLfd_ modules_ layer_ id_\n\
00098 \n\
00099 $plugin Id_ $nPlugin_\n\
00100 \n\
00101 set clsap [new ConnectorTrace/ClSAP]\n\
00102 $plugin addBin $bin_\n\
00103 $plugin addclsap $clsap\n\
00104 set clDepthP 0\n\
00105 set clDepthNC 0\n\
00106 set pluginName \"\"\n\
00107 if {$param3 == \"\"} {\n\
00108 set clDepthP $param1\n\
00109 set clDepthNC $param1\n\
00110 set pluginName $param2\n\
00111 } else {\n\
00112 set clDepthP $param1\n\
00113 set clDepthNC $param2\n\
00114 set pluginName $param3\n\
00115 }\n\
00116 if {$pluginName != \"\"} {\n\
00117 $plugin settag \"$pluginName\"\n\
00118 } elseif {[$plugin gettag] == \"---\"} {\n\
00119 $plugin settag \"$nPlugin_\"\n\
00120 }\n\
00121 $clsap set depthToP_ $clDepthP\n\
00122 $clsap set depthToNC_ $clDepthNC\n\
00123 $clsap module $plugin\n\
00124 $clsap nodecore $nodeCore_\n\
00125 $clsap preambleToPlugin \"$id_ NC [$plugin gettag]\"\n\
00126 $clsap preambleToNodeCore \"$id_ [$plugin gettag] NC\" \n\
00127 $clsap attach $traceCLfd_\n\
00128 $nodeCore_ addclsap $clsap 0\n\
00129 \n\
00130 set modules_($nPlugin_) $plugin\n\
00131 set layer_($nPlugin_) 0\n\
00132 \n\
00133 incr nPlugin_\n\
00134 }\n\
00135 \n\
00136 M_Node instproc contains {module} {\n\
00137 $self instvar modules_ layer_\n\
00138 if {$modules_([$module Id_]) == $module} {\n\
00139 return 1\n\
00140 } else {\n\
00141 return 0\n\
00142 }\n\
00143 }\n\
00144 \n\
00145 M_Node instproc addPosition {position} {\n\
00146 $self instvar nodeCore_\n\
00147 \n\
00148 $nodeCore_ position $position\n\
00149 }\n\
00150 \n\
00151 M_Node instproc position {} {\n\
00152 $self instvar nodeCore_\n\
00153 \n\
00154 return [$nodeCore_ position]\n\
00155 }\n\
00156 \n\
00157 \n\
00158 M_Node instproc setConnection {moduleUp moduleDown {trace \"notrace\"} {traceup \"\"}} {\n\
00159 $self instvar nodeCore_ tracefd_ layer_ id_\n\
00160 if {$moduleUp == \"\" || $moduleDown == \"\"} {\n\
00161 error \"The specified module does not exist !\"\n\
00162 }\n\
00163 if {![$self contains $moduleUp]} {\n\
00164 error \"The given up module does not belong to this node!!\"\n\
00165 }\n\
00166 if {![$self contains $moduleDown]} {\n\
00167 error \"The given down module does not belong to this node!!\"\n\
00168 }\n\
00169 if {$layer_([$moduleUp Id_]) < [expr $layer_([$moduleDown Id_])]} {\n\
00170 error \"The up module must be above or at most in the same layer of the down module!!\"\n\
00171 }\n\
00172 set depth 0\n\
00173 if {$trace == \"trace\"} {\n\
00174 set depth 1\n\
00175 }\n\
00176 if {[regexp {^[0-9]+$} $trace]} {\n\
00177 set depth $trace\n\
00178 }\n\
00179 set depthup $depth\n\
00180 if {$traceup != \"\"} {\n\
00181 set depthup 0\n\
00182 if {$traceup == \"trace\"} {\n\
00183 set depthup 1\n\
00184 }\n\
00185 if {[regexp {^[0-9]+$} $traceup]} {\n\
00186 set depth $traceup\n\
00187 }\n\
00188 }\n\
00189 set sap [new ConnectorTrace/SAP]\n\
00190 $sap upmodule $moduleUp\n\
00191 $sap downmodule $moduleDown\n\
00192 \n\
00193 $sap preambleUp \"$id_ [$moduleDown gettag] [$moduleUp gettag]\"\n\
00194 $sap preambleDown \"$id_ [$moduleUp gettag] [$moduleDown gettag]\"\n\
00195 $sap attach $tracefd_\n\
00196 $sap set depthDown_ $depth\n\
00197 $sap set depthUp_ $depthup\n\
00198 $moduleUp addDownsap $sap\n\
00199 $moduleDown addUpsap $sap\n\
00200 return $sap\n\
00201 }\n\
00202 \n\
00203 M_Node instproc addToChannel {channel module {trace \"notrace\"} {traceup \"\"}} {\n\
00204 $self instvar nodeCore_ id_ tracefd_\n\
00205 \n\
00206 if {$channel == \"\" || $module == \"\"} {\n\
00207 error \"The specified down module does not exist!\"\n\
00208 }\n\
00209 if {$nodeCore_ == \"\"} {\n\
00210 error \"The node must be setup first!\"\n\
00211 }\n\
00212 set depth 0\n\
00213 if {$trace == \"trace\" || $trace == \"1\"} {\n\
00214 set depth 1\n\
00215 }\n\
00216 set depthup $depth\n\
00217 if {$traceup != \"\"} {\n\
00218 if {$traceup == \"trace\" || $traceup == \"1\"} {\n\
00219 set depthup 1\n\
00220 } else {\n\
00221 set depthup 0\n\
00222 }\n\
00223 }\n\
00224 set chsap [new ConnectorTrace/ChSAP]\n\
00225 $chsap module $module\n\
00226 $chsap channel $channel\n\
00227 if {[$channel gettag] == \"---\"} {\n\
00228 set chtag \"CH\" \n\
00229 } else {\n\
00230 set chtag [$channel gettag]\n\
00231 }\n\
00232 $chsap preambleUp \"$id_ $chtag [$module gettag]\"\n\
00233 $chsap preambleDown \"$id_ [$module gettag] $chtag\"\n\
00234 $chsap attach $tracefd_\n\
00235 $chsap set depthDown_ $depth\n\
00236 $chsap set depthUp_ $depthup\n\
00237 $chsap nodeCore $nodeCore_\n\
00238 $module addDownsap $chsap\n\
00239 $channel addsap $chsap\n\
00240 return $chsap\n\
00241 }\n\
00242 \n\
00243 \n\
00244 Simulator instproc create-M_Node {{tracefd \"\"} {traceCLfd \"\"}} {\n\
00245 $self instvar nM_Node\n\
00246 \n\
00247 if {$tracefd == \"\"} {\n\
00248 set tracefd [$self get-ns-traceall]\n\
00249 }\n\
00250 if {$traceCLfd == \"\"} {\n\
00251 set traceCLfd $tracefd\n\
00252 }\n\
00253 \n\
00254 \n\
00255 set node [new M_Node]\n\
00256 $node set tracefd_ $tracefd\n\
00257 $node set traceCLfd_ $traceCLfd\n\
00258 $node set id_ $nM_Node\n\
00259 \n\
00260 $node set nodeCore_ [new NodeCore]\n\
00261 $node set bin_ [new ConnectorTrace/Bin]\n\
00262 [$node set bin_] preamble \"$nM_Node BIN\"\n\
00263 [$node set bin_] attach $tracefd\n\
00264 \n\
00265 incr nM_Node\n\
00266 return $node\n\
00267 }\n\
00268 \n\
00269 Simulator instproc use-Miracle {} {\n\
00270 $self instvar nM_Node\n\
00271 $self set nM_Node 0\n\
00272 }\n\
00273 ";
00274 #include "tclcl.h"
00275 EmbeddedTcl tclSupp(code);

Generated on Wed Nov 26 15:47:28 2008 for NS-MIRACLE library by  doxygen 1.5.2