⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 rwa_n.cpp

📁 simulation routing in wsn
💻 CPP
📖 第 1 页 / 共 4 页
字号:
	gate_nr_L = 4;
	gateL = node5_mod->findGate( "nout", gate_nr_L );
	check_gate( gateL, "node5", indexedname(b1,"nout",gate_nr_L) );

	gate_nr_R = 5;
	gateR = node4_mod->findGate( "nin", gate_nr_R );
	check_gate( gateR, "node4", indexedname(b1,"nin",gate_nr_R) );

	connect (node5_mod, gateL,
	         NULL,
	         node4_mod, gateR);

	check_error(); check_memory();
	} // end-if


	do_this_block = true; // no "if" condition
	if (do_this_block) // "if" in NED
	{
	gate_nr_L = 5;
	gateL = node4_mod->findGate( "nout", gate_nr_L );
	check_gate( gateL, "node4", indexedname(b1,"nout",gate_nr_L) );

	gate_nr_R = 4;
	gateR = node5_mod->findGate( "nin", gate_nr_R );
	check_gate( gateR, "node5", indexedname(b1,"nin",gate_nr_R) );

	connect (node4_mod, gateL,
	         NULL,
	         node5_mod, gateR);

	check_error(); check_memory();
	} // end-if


	do_this_block = true; // no "if" condition
	if (do_this_block) // "if" in NED
	{
	gate_nr_L = 13;
	gateL = node4_mod->findGate( "nout", gate_nr_L );
	check_gate( gateL, "node4", indexedname(b1,"nout",gate_nr_L) );

	gate_nr_R = 4;
	gateR = node13_mod->findGate( "nin", gate_nr_R );
	check_gate( gateR, "node13", indexedname(b1,"nin",gate_nr_R) );

	connect (node4_mod, gateL,
	         NULL,
	         node13_mod, gateR);

	check_error(); check_memory();
	} // end-if


	do_this_block = true; // no "if" condition
	if (do_this_block) // "if" in NED
	{
	gate_nr_L = 4;
	gateL = node13_mod->findGate( "nout", gate_nr_L );
	check_gate( gateL, "node13", indexedname(b1,"nout",gate_nr_L) );

	gate_nr_R = 13;
	gateR = node4_mod->findGate( "nin", gate_nr_R );
	check_gate( gateR, "node4", indexedname(b1,"nin",gate_nr_R) );

	connect (node13_mod, gateL,
	         NULL,
	         node4_mod, gateR);

	check_error(); check_memory();
	} // end-if


	do_this_block = true; // no "if" condition
	if (do_this_block) // "if" in NED
	{
	gate_nr_L = 11;
	gateL = node13_mod->findGate( "nout", gate_nr_L );
	check_gate( gateL, "node13", indexedname(b1,"nout",gate_nr_L) );

	gate_nr_R = 13;
	gateR = node11_mod->findGate( "nin", gate_nr_R );
	check_gate( gateR, "node11", indexedname(b1,"nin",gate_nr_R) );

	connect (node13_mod, gateL,
	         NULL,
	         node11_mod, gateR);

	check_error(); check_memory();
	} // end-if


	do_this_block = true; // no "if" condition
	if (do_this_block) // "if" in NED
	{
	gate_nr_L = 13;
	gateL = node11_mod->findGate( "nout", gate_nr_L );
	check_gate( gateL, "node11", indexedname(b1,"nout",gate_nr_L) );

	gate_nr_R = 11;
	gateR = node13_mod->findGate( "nin", gate_nr_R );
	check_gate( gateR, "node13", indexedname(b1,"nin",gate_nr_R) );

	connect (node11_mod, gateL,
	         NULL,
	         node13_mod, gateR);

	check_error(); check_memory();
	} // end-if


	do_this_block = true; // no "if" condition
	if (do_this_block) // "if" in NED
	{
	gate_nr_L = 12;
	gateL = node4_mod->findGate( "nout", gate_nr_L );
	check_gate( gateL, "node4", indexedname(b1,"nout",gate_nr_L) );

	gate_nr_R = 4;
	gateR = node12_mod->findGate( "nin", gate_nr_R );
	check_gate( gateR, "node12", indexedname(b1,"nin",gate_nr_R) );

	connect (node4_mod, gateL,
	         NULL,
	         node12_mod, gateR);

	check_error(); check_memory();
	} // end-if


	do_this_block = true; // no "if" condition
	if (do_this_block) // "if" in NED
	{
	gate_nr_L = 4;
	gateL = node12_mod->findGate( "nout", gate_nr_L );
	check_gate( gateL, "node12", indexedname(b1,"nout",gate_nr_L) );

	gate_nr_R = 12;
	gateR = node4_mod->findGate( "nin", gate_nr_R );
	check_gate( gateR, "node4", indexedname(b1,"nin",gate_nr_R) );

	connect (node12_mod, gateL,
	         NULL,
	         node4_mod, gateR);

	check_error(); check_memory();
	} // end-if


	do_this_block = true; // no "if" condition
	if (do_this_block) // "if" in NED
	{
	gate_nr_L = 7;
	gateL = node12_mod->findGate( "nout", gate_nr_L );
	check_gate( gateL, "node12", indexedname(b1,"nout",gate_nr_L) );

	gate_nr_R = 12;
	gateR = node7_mod->findGate( "nin", gate_nr_R );
	check_gate( gateR, "node7", indexedname(b1,"nin",gate_nr_R) );

	connect (node12_mod, gateL,
	         NULL,
	         node7_mod, gateR);

	check_error(); check_memory();
	} // end-if


	do_this_block = true; // no "if" condition
	if (do_this_block) // "if" in NED
	{
	gate_nr_L = 12;
	gateL = node7_mod->findGate( "nout", gate_nr_L );
	check_gate( gateL, "node7", indexedname(b1,"nout",gate_nr_L) );

	gate_nr_R = 7;
	gateR = node12_mod->findGate( "nin", gate_nr_R );
	check_gate( gateR, "node12", indexedname(b1,"nin",gate_nr_R) );

	connect (node7_mod, gateL,
	         NULL,
	         node12_mod, gateR);

	check_error(); check_memory();
	} // end-if


	do_this_block = true; // no "if" condition
	if (do_this_block) // "if" in NED
	{
	gate_nr_L = 6;
	gateL = node11_mod->findGate( "nout", gate_nr_L );
	check_gate( gateL, "node11", indexedname(b1,"nout",gate_nr_L) );

	gate_nr_R = 11;
	gateR = node6_mod->findGate( "nin", gate_nr_R );
	check_gate( gateR, "node6", indexedname(b1,"nin",gate_nr_R) );

	connect (node11_mod, gateL,
	         NULL,
	         node6_mod, gateR);

	check_error(); check_memory();
	} // end-if


	do_this_block = true; // no "if" condition
	if (do_this_block) // "if" in NED
	{
	gate_nr_L = 11;
	gateL = node6_mod->findGate( "nout", gate_nr_L );
	check_gate( gateL, "node6", indexedname(b1,"nout",gate_nr_L) );

	gate_nr_R = 6;
	gateR = node11_mod->findGate( "nin", gate_nr_R );
	check_gate( gateR, "node11", indexedname(b1,"nin",gate_nr_R) );

	connect (node6_mod, gateL,
	         NULL,
	         node11_mod, gateR);

	check_error(); check_memory();
	} // end-if


	do_this_block = true; // no "if" condition
	if (do_this_block) // "if" in NED
	{
	gate_nr_L = 6;
	gateL = node8_mod->findGate( "nout", gate_nr_L );
	check_gate( gateL, "node8", indexedname(b1,"nout",gate_nr_L) );

	gate_nr_R = 8;
	gateR = node6_mod->findGate( "nin", gate_nr_R );
	check_gate( gateR, "node6", indexedname(b1,"nin",gate_nr_R) );

	connect (node8_mod, gateL,
	         NULL,
	         node6_mod, gateR);

	check_error(); check_memory();
	} // end-if


	do_this_block = true; // no "if" condition
	if (do_this_block) // "if" in NED
	{
	gate_nr_L = 8;
	gateL = node6_mod->findGate( "nout", gate_nr_L );
	check_gate( gateL, "node6", indexedname(b1,"nout",gate_nr_L) );

	gate_nr_R = 6;
	gateR = node8_mod->findGate( "nin", gate_nr_R );
	check_gate( gateR, "node8", indexedname(b1,"nin",gate_nr_R) );

	connect (node6_mod, gateL,
	         NULL,
	         node8_mod, gateR);

	check_error(); check_memory();
	} // end-if


	do_this_block = true; // no "if" condition
	if (do_this_block) // "if" in NED
	{
	gate_nr_L = 8;
	gateL = node2_mod->findGate( "nout", gate_nr_L );
	check_gate( gateL, "node2", indexedname(b1,"nout",gate_nr_L) );

	gate_nr_R = 2;
	gateR = node8_mod->findGate( "nin", gate_nr_R );
	check_gate( gateR, "node8", indexedname(b1,"nin",gate_nr_R) );

	connect (node2_mod, gateL,
	         NULL,
	         node8_mod, gateR);

	check_error(); check_memory();
	} // end-if


	do_this_block = true; // no "if" condition
	if (do_this_block) // "if" in NED
	{
	gate_nr_L = 2;
	gateL = node8_mod->findGate( "nout", gate_nr_L );
	check_gate( gateL, "node8", indexedname(b1,"nout",gate_nr_L) );

	gate_nr_R = 8;
	gateR = node2_mod->findGate( "nin", gate_nr_R );
	check_gate( gateR, "node2", indexedname(b1,"nin",gate_nr_R) );

	connect (node8_mod, gateL,
	         NULL,
	         node2_mod, gateR);

	check_error(); check_memory();
	} // end-if


	do_this_block = true; // no "if" condition
	if (do_this_block) // "if" in NED
	{
	gate_nr_L = 12;
	gateL = node6_mod->findGate( "nout", gate_nr_L );
	check_gate( gateL, "node6", indexedname(b1,"nout",gate_nr_L) );

	gate_nr_R = 6;
	gateR = node12_mod->findGate( "nin", gate_nr_R );
	check_gate( gateR, "node12", indexedname(b1,"nin",gate_nr_R) );

	connect (node6_mod, gateL,
	         NULL,
	         node12_mod, gateR);

	check_error(); check_memory();
	} // end-if


	do_this_block = true; // no "if" condition
	if (do_this_block) // "if" in NED
	{
	gate_nr_L = 6;
	gateL = node12_mod->findGate( "nout", gate_nr_L );
	check_gate( gateL, "node12", indexedname(b1,"nout",gate_nr_L) );

	gate_nr_R = 12;
	gateR = node6_mod->findGate( "nin", gate_nr_R );
	check_gate( gateR, "node6", indexedname(b1,"nin",gate_nr_R) );

	connect (node12_mod, gateL,
	         NULL,
	         node6_mod, gateR);

	check_error(); check_memory();
	} // end-if


	do_this_block = true; // no "if" condition
	if (do_this_block) // "if" in NED
	{
	gate_nr_L = 7;
	gateL = node8_mod->findGate( "nout", gate_nr_L );
	check_gate( gateL, "node8", indexedname(b1,"nout",gate_nr_L) );

	gate_nr_R = 8;
	gateR = node7_mod->findGate( "nin", gate_nr_R );
	check_gate( gateR, "node7", indexedname(b1,"nin",gate_nr_R) );

	connect (node8_mod, gateL,
	         NULL,
	         node7_mod, gateR);

	check_error(); check_memory();
	} // end-if


	do_this_block = true; // no "if" condition
	if (do_this_block) // "if" in NED
	{
	gate_nr_L = 8;
	gateL = node7_mod->findGate( "nout", gate_nr_L );
	check_gate( gateL, "node7", indexedname(b1,"nout",gate_nr_L) );

	gate_nr_R = 7;
	gateR = node8_mod->findGate( "nin", gate_nr_R );
	check_gate( gateR, "node8", indexedname(b1,"nin",gate_nr_R) );

	connect (node7_mod, gateL,
	         NULL,
	         node8_mod, gateR);

	check_error(); check_memory();
	} // end-if


	do_this_block = true; // no "if" condition
	if (do_this_block) // "if" in NED
	{
	gate_nr_L = 3;
	gateL = node1_mod->findGate( "nout", gate_nr_L );
	check_gate( gateL, "node1", indexedname(b1,"nout",gate_nr_L) );

	gate_nr_R = 1;
	gateR = node3_mod->findGate( "nin", gate_nr_R );
	check_gate( gateR, "node3", indexedname(b1,"nin",gate_nr_R) );

	connect (node1_mod, gateL,
	         NULL,
	         node3_mod, gateR);

	check_error(); check_memory();
	} // end-if

	mod->setDisplayString(dispENCLOSINGMOD, "p=18,18;b=696,368" );

	check_error(); check_memory();
}

class theRWA : public cNetworkType
{
  public:
    theRWA(const char *name) : cNetworkType(name) {}
    theRWA(const theRWA& n)  {setName(n.name());operator=(n);}
    virtual void setupNetwork();
};

Define_Network( theRWA );

void theRWA::setupNetwork()
{

	// temporary variables:
	cPar value, *par;
	cPar::ExprElem *expr_tab; int k;
	cFunctionType *functype;
	const char *type_name;
	char b1[64], b2[64];
	cArray machines;
	bool islocal, do_this_block;
	int n;

	// an empty actual machine list for the next module
	par = new cPar();
	*par = ev.getPhysicalMachineFor("default");
	machines.add( par );
	check_error(); check_memory();

	// system module creation
	cModuleType *modtype;
	modtype = findModuleType( "RWA" );
	check_modtype( modtype, "RWA" );
	cModule *theRWA_mod;

	// module creation:
	islocal = simulation.netInterface()==NULL ||
	          simulation.netInterface()->isLocalMachineIn( machines );
	if (!islocal)
	    throw new cException("Local machine `%s' is not among machines specified for this network",
	              simulation.netInterface()->localhost());
	theRWA_mod = modtype->create( "theRWA", NULL, islocal);
	check_error(); check_memory();

	// set machine list:
	theRWA_mod->setMachinePar( "default", ev.getPhysicalMachineFor("default") );
	check_error(); check_memory();

	// 'parameters:' section
	n = theRWA_mod->params();
	for(k=0;k<n;k++)
	   if(theRWA_mod->par(k).isInput())
	      {theRWA_mod->par(k).read();check_error();}

	// build function call:
	theRWA_mod->buildInside();
	machines.clear();

	check_error(); check_memory();
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -