//----------------------------------------- // // Generated by NEDC version 2.3b2 // date: Sat Jun 07 16:18:12 2003 // // Input file: sink1.ned // Output file: sink1_n.cc //----------------------------------------- #include #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: fifonet1.ned //-------------------------------------------- ModuleInterface( FifoNet1 ) Machine( default ) EndInterface Register_ModuleInterface( FifoNet1 ) class FifoNet1 : public cCompoundModule { public: FifoNet1(const char *name, cModule *parentmod) : cCompoundModule(name, parentmod) {} protected: virtual void doBuildInside(); }; Define_Module( FifoNet1 ); void FifoNet1::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; // Submodules: cModuleType *modtype = NULL; long sub_nr = 0; long sub_i = 0; // gen modtype = findModuleType( "FF2Generator" ); check_modtype( modtype, "FF2Generator" ); cModule *gen_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 ); gen_mod = modtype->create( "gen", mod, islocal); check_error(); check_memory(); // set machine list: gen_mod->setMachinePar( "default", ((cPar *)machines[0])->stringValue() ); check_error(); check_memory(); // 'parameters:' section value.cancelRedirection(); value = 0L; value.setPrompt( NULL ); value.setInput( true ); par = &(gen_mod->par("num_messages")); check_param(par, "num_messages"); *par = value; value.cancelRedirection(); value = 0L; value.setPrompt( NULL ); value.setInput( true ); par = &(gen_mod->par("ia_time")); check_param(par, "ia_time"); *par = value; value.cancelRedirection(); value = 0L; value.setPrompt( NULL ); value.setInput( true ); par = &(gen_mod->par("msg_length")); check_param(par, "msg_length"); *par = value; n = gen_mod->params(); for(k=0;kpar(k).isInput()) {gen_mod->par(k).read();check_error();} gen_mod->setDisplayString(dispSUBMOD, "p=76,78;i=gen" ); // build function call: gen_mod->buildInside(); machines.clear(); // fifo modtype = findModuleType( "FF2PacketFifo" ); check_modtype( modtype, "FF2PacketFifo" ); cModule *fifo_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 ); fifo_mod = modtype->create( "fifo", mod, islocal); check_error(); check_memory(); // set machine list: fifo_mod->setMachinePar( "default", ((cPar *)machines[0])->stringValue() ); check_error(); check_memory(); // 'parameters:' section value.cancelRedirection(); value = 0L; value.setPrompt( NULL ); value.setInput( true ); par = &(fifo_mod->par("service_time")); check_param(par, "service_time"); *par = value; n = fifo_mod->params(); for(k=0;kpar(k).isInput()) {fifo_mod->par(k).read();check_error();} fifo_mod->setDisplayString(dispSUBMOD, "p=164,78;i=queue" ); // build function call: fifo_mod->buildInside(); machines.clear(); // sink modtype = findModuleType( "FF2Sink" ); check_modtype( modtype, "FF2Sink" ); cModule *sink_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 ); sink_mod = modtype->create( "sink", mod, islocal); check_error(); check_memory(); // set machine list: sink_mod->setMachinePar( "default", ((cPar *)machines[0])->stringValue() ); check_error(); check_memory(); n = sink_mod->params(); for(k=0;kpar(k).isInput()) {sink_mod->par(k).read();check_error();} sink_mod->setDisplayString(dispSUBMOD, "p=244,78;i=sink" ); // build function call: sink_mod->buildInside(); machines.clear(); // Connections: cLinkType *link_p; cPar *delay_p, *error_p, *datarate_p; int gateL, gateR; long mod_nr_L, mod_nr_R, gate_nr_L, gate_nr_R; do_this_block = true; // no "if" condition if (do_this_block) // "if" in NED { gateL = gen_mod->findGate( "out" ); check_gate( gateL, "gen", "out" ); gateR = fifo_mod->findGate( "in" ); check_gate( gateR, "fifo", "in" ); connect (gen_mod, gateL, NULL, fifo_mod, gateR); check_error(); check_memory(); } // end-if do_this_block = true; // no "if" condition if (do_this_block) // "if" in NED { gateL = fifo_mod->findGate( "out" ); check_gate( gateL, "fifo", "out" ); gateR = sink_mod->findGate( "in" ); check_gate( gateR, "sink", "in" ); connect (fifo_mod, gateL, NULL, sink_mod, gateR); check_error(); check_memory(); } // end-if mod->checkInternalConnections(); check_error(); check_memory(); } class fifonet1 : public cNetworkType { public: fifonet1(const char *name) : cNetworkType(name) {} fifonet1(const fifonet1& n) {setName(n.name());operator=(n);} virtual void setupNetwork(); }; Define_Network( fifonet1 ); void fifonet1::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( "FifoNet1" ); check_modtype( modtype, "FifoNet1" ); cModule *fifonet1_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()); fifonet1_mod = modtype->create( "fifonet1", NULL, islocal); check_error(); check_memory(); // set machine list: fifonet1_mod->setMachinePar( "default", ev.getPhysicalMachineFor("default") ); check_error(); check_memory(); n = fifonet1_mod->params(); for(k=0;kpar(k).isInput()) {fifonet1_mod->par(k).read();check_error();} // build function call: fifonet1_mod->buildInside(); machines.clear(); check_error(); check_memory(); }