sources:
fifo1.cpp (4.0k)
fifo1.h (1.2k)
fifo1_n.cpp (4.0k)
fifonet1_n.cpp (10.2k)
gen1.cpp (1.3k)
gen1.h (443 bytes)
gen1_n.cpp (4.1k)
sink1.cpp (1.4k)
sink1.h (503 bytes)
sink1_n.cpp (3.9k)


website:
more info here


screenshot:
studies/performance/Performance-Code4/fifonet1_n.cpp
download file

  1 //-----------------------------------------
  2 //
  3 // Generated by NEDC version 2.3b2
  4 // date: Sat Jun 07 16:18:12 2003
  5 //
  6 // Input file: sink1.ned
  7 // Output file: sink1_n.cc
  8 //-----------------------------------------
  9
 10
 11 #include <math.h>
 12 #include "omnetpp.h"
 13
 14 #define check_error() \
 15     {(void)0;}
 16 #define check_memory() \
 17     {if (memoryIsLow()) {throw new cException(eNOMEM); }}
 18 #define check_module_count(num, mod, parentmod) \
 19     {if ((int)num<=0) {throw new cException("Negative or zero module vector size %s[%d] in compound module %s", ===>\<===
 20                           mod,(int)num,parentmod)
;}}
 21 #define check_gate_count(num, mod, gate, parentmod) \
 22     {if ((int)num<0) {throw new cException("Negative gate vector size %s.%s[%d] in compound module %s", ===>\<===
 23                           mod,gate,(int)num,parentmod)
;}}
 24 #define check_loop_bounds(lower, upper, parentmod) \
 25     {if ((int)lower<0) ===>\<===
 26         {throw new cException("Bad loop bounds (%d..%d) in compound module %s", ===>\<===
 27                  (int)lower,(int)upper,parentmod)
;}}
 28 #define check_module_index(index,modvar,modname,parentmod) \
 29     {if (index<0 || index>=modvar[0]->size()) {throw new cException("Bad submodule index %s[%d] in compound module %s", ===>\<===
 30           modname,(int)index,parentmod)
;}}
 31 #define check_channel_params(delay, err, channel) \
 32     {if ((double)delay<0.0) ===>\<===
 33         {throw new cException("Negative delay value %lf in channel %s",(double)delay,channel);} ===>\<===
 34      if ((double)err<0.0 || (double)err>1.0) ===>\<===
 35         {throw new cException("Incorrect error value %lf in channel %s",(double)err,channel);}}
 36 #define check_modtype(modtype, modname) \
 37     {if ((modtype)==NULL) {throw new cException("Simple module type definition %s not found", ===>\<===
 38                                      modname)
;}}
 39 #define check_function(funcptr, funcname) \
 40     {if ((funcptr)==NULL) {throw new cException("Function %s not found", ===>\<===
 41                                      funcname)
;}}
 42 #define check_function_retnull(funcptr, funcname) \
 43     {if ((funcptr)==NULL) {throw new cException("Function %s not found", ===>\<===
 44                                      funcname)
;return NULL;}}
 45 #define check_gate(gateindex, modname, gatename) \
 46     {if ((int)gateindex==-1) {throw new cException("Gate %s.%s not found",modname,gatename);}}
 47 #define check_anc_param(ptr,parname,compoundmod) \
 48     {if ((ptr)==NULL) {throw new cException("Unknown ancestor parameter named %s in compound module %s", ===>\<===
 49                                 parname,compoundmod)
;}}
 50 #define check_param(ptr,parname) \
 51     {if ((ptr)==NULL) {throw new cException("Unknown parameter named %s", ===>\<===
 52                                 parname)
;}}
 53 #ifndef __cplusplus
 54 # error Compile as C++!
 55 #endif
 56 #ifdef __BORLANDC__
 57 # if !defined(__FLAT__) && !defined(__LARGE__)
 58 # error Compile as 16-bit LARGE model or 32-bit DPMI!
 59 # endif
 60 #endif
 61
 62 // Disable warnings about unused variables:
 63 #ifdef _MSC_VER
 64 # pragma warning(disable:4101)
 65 #endif
 66 #ifdef __BORLANDC__
 67 # pragma warn -waus
 68 # pragma warn -wuse
 69 #endif
 70 // for GCC, seemingly there's no way to emulate the -Wunused command-line
 71 // flag from a source file...
 72
 73 // Version check
 74 #define NEDC_VERSION 0x0203
 75 #if (NEDC_VERSION!=OMNETPP_VERSION)
 76 # error Version mismatch! Probably this file was generated by an earlier version of nedc: 'make clean' should help.
 77 #endif
 78
 79 //--------------------------------------------
 80 // Following code generated from: fifonet1.ned
 81 //--------------------------------------------
 82
 83 ModuleInterface( FifoNet1 )
 84     Machine( default )
 85 EndInterface
 86 Register_ModuleInterface( FifoNet1 )
 87
 88 class FifoNet1 : public cCompoundModule {
 89   public:
 90     FifoNet1(const char *name, cModule *parentmod) :
 91       cCompoundModule(name, parentmod) {}
 92   protected:
 93     virtual void doBuildInside();
 94 };
 95
 96 Define_Module( FifoNet1 );
 97
 98 void FifoNet1::doBuildInside()
 99 {
100     cModule *mod = this;
101     // temporary variables:
102     cPar value, *par;
103     cPar::ExprElem *expr_tab; int k;
104     cFunctionType *functype;
105     const char *type_name;
106     char b1[64], b2[64];
107     cArray machines;
108     bool islocal, do_this_block;
109     int n;
110
111     // Submodules:
112     cModuleType *modtype = NULL;
113     long sub_nr = 0;
114     long sub_i = 0;
115
116     // gen
117     modtype = findModuleType( "FF2Generator" );
118     check_modtype( modtype, "FF2Generator" );
119     cModule *gen_mod;
120
121     // an empty actual machine list for the next module
122     par = new cPar();
123     *par = mod->machinePar("default");
124     machines.add( par );
125     check_error(); check_memory();
126
127     // module creation:
128     islocal = simulation.netInterface()==NULL ||
129               simulation.netInterface()->isLocalMachineIn( machines );
130     gen_mod = modtype->create( "gen", mod, islocal);
131     check_error(); check_memory();
132
133     // set machine list:
134     gen_mod->setMachinePar( "default", ((cPar *)machines[0])->stringValue() );
135     check_error(); check_memory();
136
137     // 'parameters:' section
138     value.cancelRedirection();
139     value = 0L;
140     value.setPrompt( NULL );
141     value.setInput( true );
142     par = &(gen_mod->par("num_messages"));
143     check_param(par, "num_messages");
144     *par = value;
145
146     value.cancelRedirection();
147     value = 0L;
148     value.setPrompt( NULL );
149     value.setInput( true );
150     par = &(gen_mod->par("ia_time"));
151     check_param(par, "ia_time");
152     *par = value;
153
154     value.cancelRedirection();
155     value = 0L;
156     value.setPrompt( NULL );
157     value.setInput( true );
158     par = &(gen_mod->par("msg_length"));
159     check_param(par, "msg_length");
160     *par = value;
161
162     n = gen_mod->params();
163     for(k=0;k<n;k++)
164        if(gen_mod->par(k).isInput())
165           {gen_mod->par(k).read();check_error();}
166
167     gen_mod->setDisplayString(dispSUBMOD, "p=76,78;i=gen" );
168
169     // build function call:
170     gen_mod->buildInside();
171     machines.clear();
172
173     // fifo
174     modtype = findModuleType( "FF2PacketFifo" );
175     check_modtype( modtype, "FF2PacketFifo" );
176     cModule *fifo_mod;
177
178     // an empty actual machine list for the next module
179     par = new cPar();
180     *par = mod->machinePar("default");
181     machines.add( par );
182     check_error(); check_memory();
183
184     // module creation:
185     islocal = simulation.netInterface()==NULL ||
186               simulation.netInterface()->isLocalMachineIn( machines );
187     fifo_mod = modtype->create( "fifo", mod, islocal);
188     check_error(); check_memory();
189
190     // set machine list:
191     fifo_mod->setMachinePar( "default", ((cPar *)machines[0])->stringValue() );
192     check_error(); check_memory();
193
194     // 'parameters:' section
195     value.cancelRedirection();
196     value = 0L;
197     value.setPrompt( NULL );
198     value.setInput( true );
199     par = &(fifo_mod->par("service_time"));
200     check_param(par, "service_time");
201     *par = value;
202
203     n = fifo_mod->params();
204     for(k=0;k<n;k++)
205        if(fifo_mod->par(k).isInput())
206           {fifo_mod->par(k).read();check_error();}
207
208     fifo_mod->setDisplayString(dispSUBMOD, "p=164,78;i=queue" );
209
210     // build function call:
211     fifo_mod->buildInside();
212     machines.clear();
213
214     // sink
215     modtype = findModuleType( "FF2Sink" );
216     check_modtype( modtype, "FF2Sink" );
217     cModule *sink_mod;
218
219     // an empty actual machine list for the next module
220     par = new cPar();
221     *par = mod->machinePar("default");
222     machines.add( par );
223     check_error(); check_memory();
224
225     // module creation:
226     islocal = simulation.netInterface()==NULL ||
227               simulation.netInterface()->isLocalMachineIn( machines );
228     sink_mod = modtype->create( "sink", mod, islocal);
229     check_error(); check_memory();
230
231     // set machine list:
232     sink_mod->setMachinePar( "default", ((cPar *)machines[0])->stringValue() );
233     check_error(); check_memory();
234
235     n = sink_mod->params();
236     for(k=0;k<n;k++)
237        if(sink_mod->par(k).isInput())
238           {sink_mod->par(k).read();check_error();}
239
240     sink_mod->setDisplayString(dispSUBMOD, "p=244,78;i=sink" );
241
242     // build function call:
243     sink_mod->buildInside();
244     machines.clear();
245
246     // Connections:
247     cLinkType *link_p;
248     cPar *delay_p, *error_p, *datarate_p;
249     int gateL, gateR;
250     long mod_nr_L, mod_nr_R, gate_nr_L, gate_nr_R;
251
252     do_this_block = true; // no "if" condition
253     if (do_this_block) // "if" in NED
254     {
255     gateL = gen_mod->findGate( "out" );
256     check_gate( gateL, "gen", "out" );
257
258     gateR = fifo_mod->findGate( "in" );
259     check_gate( gateR, "fifo", "in" );
260
261     connect (gen_mod, gateL,
262              NULL,
263              fifo_mod, gateR)
;
264
265     check_error(); check_memory();
266     } // end-if
267
268
269     do_this_block = true; // no "if" condition
270     if (do_this_block) // "if" in NED
271     {
272     gateL = fifo_mod->findGate( "out" );
273     check_gate( gateL, "fifo", "out" );
274
275     gateR = sink_mod->findGate( "in" );
276     check_gate( gateR, "sink", "in" );
277
278     connect (fifo_mod, gateL,
279              NULL,
280              sink_mod, gateR)
;
281
282     check_error(); check_memory();
283     } // end-if
284
285     mod->checkInternalConnections();
286     check_error(); check_memory();
287 }
288
289 class fifonet1 : public cNetworkType {
290   public:
291     fifonet1(const char *name) : cNetworkType(name) {}
292     fifonet1(const fifonet1& n)  {setName(n.name());operator=(n);}
293     virtual void setupNetwork();
294 };
295
296 Define_Network( fifonet1 );
297
298 void fifonet1::setupNetwork()
299 {
300
301     // temporary variables:
302     cPar value, *par;
303     cPar::ExprElem *expr_tab; int k;
304     cFunctionType *functype;
305     const char *type_name;
306     char b1[64], b2[64];
307     cArray machines;
308     bool islocal, do_this_block;
309     int n;
310
311     // an empty actual machine list for the next module
312     par = new cPar();
313     *par = ev.getPhysicalMachineFor("default");
314     machines.add( par );
315     check_error(); check_memory();
316
317     // system module creation
318     cModuleType *modtype;
319     modtype = findModuleType( "FifoNet1" );
320     check_modtype( modtype, "FifoNet1" );
321     cModule *fifonet1_mod;
322
323     // module creation:
324     islocal = simulation.netInterface()==NULL ||
325               simulation.netInterface()->isLocalMachineIn( machines );
326     if (!islocal)
327         throw new cException("Local machine `%s' is not among machines specified for this network",
328                   simulation.netInterface()->localhost())
;
329     fifonet1_mod = modtype->create( "fifonet1", NULL, islocal);
330     check_error(); check_memory();
331
332     // set machine list:
333     fifonet1_mod->setMachinePar( "default", ev.getPhysicalMachineFor("default") );
334     check_error(); check_memory();
335
336     n = fifonet1_mod->params();
337     for(k=0;k<n;k++)
338        if(fifonet1_mod->par(k).isInput())
339           {fifonet1_mod->par(k).read();check_error();}
340
341     // build function call:
342     fifonet1_mod->buildInside();
343     machines.clear();
344
345     check_error(); check_memory();
346 }
347
348
349