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

📄 rwa_n.cpp

📁 simulation routing in wsn
💻 CPP
📖 第 1 页 / 共 4 页
字号:
//-----------------------------------------
//
// Generated by NEDC version 2.3
// date:	Fri Mar 18 00:30:59 2005
//
// Input file:	simple0.ned
// Output file:	simple0_n.cpp
//-----------------------------------------


#include <math.h>
#include "omnetpp.h"

#define check_error() \
    {(void)0;}
#define check_memory() \
    {if (memoryIsLow()) {throw new cException(eNOMEM); }}
#define check_module_count(num, mod, parentmod) \
    {if ((int)num<=0) {throw new cException("Negative or zero module vector size %s[%d] in compound module %s", \
                          mod,(int)num,parentmod);}}
#define check_gate_count(num, mod, gate, parentmod) \
    {if ((int)num<0) {throw new cException("Negative gate vector size %s.%s[%d] in compound module %s", \
                          mod,gate,(int)num,parentmod);}}
#define check_loop_bounds(lower, upper, parentmod) \
    {if ((int)lower<0) \
        {throw new cException("Bad loop bounds (%d..%d) in compound module %s", \
                 (int)lower,(int)upper,parentmod);}}
#define check_module_index(index,modvar,modname,parentmod) \
    {if (index<0 || index>=modvar[0]->size()) {throw new cException("Bad submodule index %s[%d] in compound module %s", \
          modname,(int)index,parentmod);}}
#define check_channel_params(delay, err, channel) \
    {if ((double)delay<0.0) \
        {throw new cException("Negative delay value %lf in channel %s",(double)delay,channel);} \
     if ((double)err<0.0 || (double)err>1.0) \
        {throw new cException("Incorrect error value %lf in channel %s",(double)err,channel);}}
#define check_modtype(modtype, modname) \
    {if ((modtype)==NULL) {throw new cException("Simple module type definition %s not found", \
                                     modname);}}
#define check_function(funcptr, funcname) \
    {if ((funcptr)==NULL) {throw new cException("Function %s not found", \
                                     funcname);}}
#define check_function_retnull(funcptr, funcname) \
    {if ((funcptr)==NULL) {throw new cException("Function %s not found", \
                                     funcname);return NULL;}}
#define check_gate(gateindex, modname, gatename) \
    {if ((int)gateindex==-1) {throw new cException("Gate %s.%s not found",modname,gatename);}}
#define check_anc_param(ptr,parname,compoundmod) \
    {if ((ptr)==NULL) {throw new cException("Unknown ancestor parameter named %s in compound module %s", \
                                parname,compoundmod);}}
#define check_param(ptr,parname) \
    {if ((ptr)==NULL) {throw new cException("Unknown parameter named %s", \
                                parname);}}
#ifndef __cplusplus
#  error Compile as C++!
#endif
#ifdef __BORLANDC__
#  if !defined(__FLAT__) && !defined(__LARGE__)
#    error Compile as 16-bit LARGE model or 32-bit DPMI!
#  endif
#endif

// Disable warnings about unused variables:
#ifdef _MSC_VER
#  pragma warning(disable:4101)
#endif
#ifdef __BORLANDC__
#  pragma warn -waus
#  pragma warn -wuse
#endif
// for GCC, seemingly there's no way to emulate the -Wunused command-line
// flag from a source file...

// Version check
#define NEDC_VERSION 0x0203
#if (NEDC_VERSION!=OMNETPP_VERSION)
#    error Version mismatch! Probably this file was generated by an earlier version of nedc: 'make clean' should help.
#endif

//--------------------------------------------
// Following code generated from: RWA.ned
//--------------------------------------------

ModuleInterface( RWA )
	Machine( default )
	Parameter( num_node, ParType_Numeric ParType_Const )
EndInterface

Register_ModuleInterface( RWA )

class RWA : public cCompoundModule
{
  public:
    RWA(const char *name, cModule *parentmod) :
      cCompoundModule(name, parentmod) {}
  protected:
    virtual void doBuildInside();
};

Define_Module( RWA );

void RWA::doBuildInside()
{
	cModule *mod = this;
	// 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;

	// const parameters:
	// Submodules:
	cModuleType *modtype = NULL;
	long sub_nr = 0;
	long sub_i = 0;

	// node0
	modtype = findModuleType( "node" );
	check_modtype( modtype, "node" );
	cModule *node0_mod;

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

	// module creation:
	islocal = simulation.netInterface()==NULL ||
	          simulation.netInterface()->isLocalMachineIn( machines );
	node0_mod = modtype->create( "node0", mod, islocal);
	check_error(); check_memory();

	// set machine list:
	node0_mod->setMachinePar( "default", ((cPar *)machines[0])->stringValue() );
	check_error(); check_memory();

	// 'parameters:' section
	par = &mod->ancestorPar( "num_node" );
	check_anc_param(par,"num_node","RWA");
	value.cancelRedirection();
	value = *par;
	par = &(node0_mod->par("num_node"));
	check_param(par, "num_node");
	*par = value;

	value.cancelRedirection();
	value = 0L;
	value.setPrompt( NULL );
	value.setInput( true );
	par = &(node0_mod->par("convert"));
	check_param(par, "convert");
	*par = value;

	par = &(node0_mod->par("nodeID"));
	check_param(par, "nodeID");
	*par = 0;

	n = node0_mod->params();
	for(k=0;k<n;k++)
	   if(node0_mod->par(k).isInput())
	      {node0_mod->par(k).read();check_error();}

	// 'gatesizes:' section
	n = mod->par( "num_node" );
	check_gate_count( n, "node0","nin","RWA");
	node0_mod->setGateSize("nin", n );

	n = mod->par( "num_node" );
	check_gate_count( n, "node0","nout","RWA");
	node0_mod->setGateSize("nout", n );

	node0_mod->setDisplayString(dispSUBMOD, "i=xconn;p=48,200;b=32,30" );

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

	// node1
	modtype = findModuleType( "node" );
	check_modtype( modtype, "node" );
	cModule *node1_mod;

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

	// module creation:
	islocal = simulation.netInterface()==NULL ||
	          simulation.netInterface()->isLocalMachineIn( machines );
	node1_mod = modtype->create( "node1", mod, islocal);
	check_error(); check_memory();

	// set machine list:
	node1_mod->setMachinePar( "default", ((cPar *)machines[0])->stringValue() );
	check_error(); check_memory();

	// 'parameters:' section
	par = &mod->ancestorPar( "num_node" );
	check_anc_param(par,"num_node","RWA");
	value.cancelRedirection();
	value = *par;
	par = &(node1_mod->par("num_node"));
	check_param(par, "num_node");
	*par = value;

	value.cancelRedirection();
	value = 0L;
	value.setPrompt( NULL );
	value.setInput( true );
	par = &(node1_mod->par("convert"));
	check_param(par, "convert");
	*par = value;

	par = &(node1_mod->par("nodeID"));
	check_param(par, "nodeID");
	*par = 1;

	n = node1_mod->params();
	for(k=0;k<n;k++)
	   if(node1_mod->par(k).isInput())
	      {node1_mod->par(k).read();check_error();}

	// 'gatesizes:' section
	n = mod->par( "num_node" );
	check_gate_count( n, "node1","nin","RWA");
	node1_mod->setGateSize("nin", n );

	n = mod->par( "num_node" );
	check_gate_count( n, "node1","nout","RWA");
	node1_mod->setGateSize("nout", n );

	node1_mod->setDisplayString(dispSUBMOD, "p=108,56;i=xconn;b=32,30" );

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

	// node2
	modtype = findModuleType( "node" );
	check_modtype( modtype, "node" );
	cModule *node2_mod;

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

	// module creation:
	islocal = simulation.netInterface()==NULL ||
	          simulation.netInterface()->isLocalMachineIn( machines );
	node2_mod = modtype->create( "node2", mod, islocal);
	check_error(); check_memory();

	// set machine list:
	node2_mod->setMachinePar( "default", ((cPar *)machines[0])->stringValue() );
	check_error(); check_memory();

	// 'parameters:' section
	par = &mod->ancestorPar( "num_node" );
	check_anc_param(par,"num_node","RWA");
	value.cancelRedirection();
	value = *par;
	par = &(node2_mod->par("num_node"));
	check_param(par, "num_node");
	*par = value;

	value.cancelRedirection();
	value = 0L;
	value.setPrompt( NULL );
	value.setInput( true );
	par = &(node2_mod->par("convert"));
	check_param(par, "convert");
	*par = value;

	par = &(node2_mod->par("nodeID"));
	check_param(par, "nodeID");
	*par = 2;

	n = node2_mod->params();
	for(k=0;k<n;k++)
	   if(node2_mod->par(k).isInput())
	      {node2_mod->par(k).read();check_error();}

	// 'gatesizes:' section
	n = mod->par( "num_node" );
	check_gate_count( n, "node2","nin","RWA");
	node2_mod->setGateSize("nin", n );

	n = mod->par( "num_node" );
	check_gate_count( n, "node2","nout","RWA");
	node2_mod->setGateSize("nout", n );

	node2_mod->setDisplayString(dispSUBMOD, "p=176,168;i=xconn;b=32,30" );

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

	// node3
	modtype = findModuleType( "node" );
	check_modtype( modtype, "node" );
	cModule *node3_mod;

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

	// module creation:
	islocal = simulation.netInterface()==NULL ||
	          simulation.netInterface()->isLocalMachineIn( machines );
	node3_mod = modtype->create( "node3", mod, islocal);
	check_error(); check_memory();

	// set machine list:
	node3_mod->setMachinePar( "default", ((cPar *)machines[0])->stringValue() );
	check_error(); check_memory();

	// 'parameters:' section
	par = &mod->ancestorPar( "num_node" );
	check_anc_param(par,"num_node","RWA");
	value.cancelRedirection();
	value = *par;
	par = &(node3_mod->par("num_node"));
	check_param(par, "num_node");
	*par = value;

	value.cancelRedirection();
	value = 0L;
	value.setPrompt( NULL );
	value.setInput( true );
	par = &(node3_mod->par("convert"));
	check_param(par, "convert");
	*par = value;

	par = &(node3_mod->par("nodeID"));
	check_param(par, "nodeID");
	*par = 3;

	n = node3_mod->params();
	for(k=0;k<n;k++)
	   if(node3_mod->par(k).isInput())
	      {node3_mod->par(k).read();check_error();}

	// 'gatesizes:' section
	n = mod->par( "num_node" );
	check_gate_count( n, "node3","nin","RWA");
	node3_mod->setGateSize("nin", n );

	n = mod->par( "num_node" );
	check_gate_count( n, "node3","nout","RWA");
	node3_mod->setGateSize("nout", n );

	node3_mod->setDisplayString(dispSUBMOD, "p=96,280;i=xconn;b=32,30" );

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

	// node4
	modtype = findModuleType( "node" );
	check_modtype( modtype, "node" );
	cModule *node4_mod;

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

	// module creation:
	islocal = simulation.netInterface()==NULL ||
	          simulation.netInterface()->isLocalMachineIn( machines );
	node4_mod = modtype->create( "node4", mod, islocal);
	check_error(); check_memory();

	// set machine list:
	node4_mod->setMachinePar( "default", ((cPar *)machines[0])->stringValue() );
	check_error(); check_memory();

	// 'parameters:' section
	par = &mod->ancestorPar( "num_node" );
	check_anc_param(par,"num_node","RWA");
	value.cancelRedirection();
	value = *par;
	par = &(node4_mod->par("num_node"));
	check_param(par, "num_node");
	*par = value;

	value.cancelRedirection();
	value = 0L;
	value.setPrompt( NULL );
	value.setInput( true );
	par = &(node4_mod->par("convert"));
	check_param(par, "convert");
	*par = value;

	par = &(node4_mod->par("nodeID"));
	check_param(par, "nodeID");
	*par = 4;

	n = node4_mod->params();
	for(k=0;k<n;k++)
	   if(node4_mod->par(k).isInput())
	      {node4_mod->par(k).read();check_error();}

	// 'gatesizes:' section
	n = mod->par( "num_node" );
	check_gate_count( n, "node4","nin","RWA");
	node4_mod->setGateSize("nin", n );

	n = mod->par( "num_node" );
	check_gate_count( n, "node4","nout","RWA");
	node4_mod->setGateSize("nout", n );

	node4_mod->setDisplayString(dispSUBMOD, "p=392,336;i=xconn;b=32,30" );

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

	// node5
	modtype = findModuleType( "node" );
	check_modtype( modtype, "node" );
	cModule *node5_mod;

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

	// module creation:
	islocal = simulation.netInterface()==NULL ||
	          simulation.netInterface()->isLocalMachineIn( machines );
	node5_mod = modtype->create( "node5", mod, islocal);
	check_error(); check_memory();

	// set machine list:
	node5_mod->setMachinePar( "default", ((cPar *)machines[0])->stringValue() );
	check_error(); check_memory();

	// 'parameters:' section
	par = &mod->ancestorPar( "num_node" );
	check_anc_param(par,"num_node","RWA");
	value.cancelRedirection();
	value = *par;
	par = &(node5_mod->par("num_node"));
	check_param(par, "num_node");
	*par = value;

	value.cancelRedirection();
	value = 0L;
	value.setPrompt( NULL );
	value.setInput( true );
	par = &(node5_mod->par("convert"));
	check_param(par, "convert");

⌨️ 快捷键说明

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