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
 87 Register_ModuleInterface( FifoNet1 )
 88
 89 class FifoNet1 : public cCompoundModule
 90 {
 91   public:
 92     FifoNet1(const char *name, cModule *parentmod) :
 93       cCompoundModule(name, parentmod) {}
 94   protected:
 95     virtual void doBuildInside();
 96 };
 97
 98 Define_Module( FifoNet1 );
 99
100 void FifoNet1::doBuildInside()
101 {
102     cModule *mod = this;
103     // temporary variables:
104     cPar value, *par;
105     cPar::ExprElem *expr_tab; int k;
106     cFunctionType *functype;
107     const char *type_name;
108     char b1[64], b2[64];
109     cArray machines;
110     bool islocal, do_this_block;
111     int n;
112
113     // Submodules:
114     cModuleType *modtype = NULL;
115     long sub_nr = 0;
116     long sub_i = 0;
117
118     // gen
119     modtype = findModuleType( "FF2Generator" );
120     check_modtype( modtype, "FF2Generator" );
121     cModule *gen_mod;
122
123     // an empty actual machine list for the next module
124     par = new cPar();
125     *par = mod->machinePar("default");
126     machines.add( par );
127     check_error(); check_memory();
128
129     // module creation:
130     islocal = simulation.netInterface()==NULL ||
131               simulation.netInterface()->isLocalMachineIn( machines );
132     gen_mod = modtype->create( "gen", mod, islocal);
133     check_error(); check_memory();
134
135     // set machine list:
136     gen_mod->setMachinePar( "default", ((cPar *)machines[0])->stringValue() );
137     check_error(); check_memory();
138
139     // 'parameters:' section
140     value.cancelRedirection();
141     value = 0L;
142     value.setPrompt( NULL );
143     value.setInput( true );
144     par = &(gen_mod->par("num_messages"));
145     check_param(par, "num_messages");
146     *par = value;
147
148     value.cancelRedirection();
149     value = 0L;
150     value.setPrompt( NULL );
151     value.setInput( true );
152     par = &(gen_mod->par("ia_time"));
153     check_param(par, "ia_time");
154     *par = value;
155
156     value.cancelRedirection();
157     value = 0L;
158     value.setPrompt( NULL );
159     value.setInput( true );
160     par = &(gen_mod->par("msg_length"));
161     check_param(par, "msg_length");
162     *par = value;
163
164     n = gen_mod->params();
165     for(k=0;k<n;k++)
166        if(gen_mod->par(k).isInput())
167           {gen_mod->par(k).read();check_error();}
168
169     gen_mod->setDisplayString(dispSUBMOD, "p=76,78;i=gen" );
170
171     // build function call:
172     gen_mod->buildInside();
173     machines.clear();
174
175     // fifo
176     modtype = findModuleType( "FF2PacketFifo" );
177     check_modtype( modtype, "FF2PacketFifo" );
178     cModule *fifo_mod;
179
180     // an empty actual machine list for the next module
181     par = new cPar();
182     *par = mod->machinePar("default");
183     machines.add( par );
184     check_error(); check_memory();
185
186     // module creation:
187     islocal = simulation.netInterface()==NULL ||
188               simulation.netInterface()->isLocalMachineIn( machines );
189     fifo_mod = modtype->create( "fifo", mod, islocal);
190     check_error(); check_memory();
191
192     // set machine list:
193     fifo_mod->setMachinePar( "default", ((cPar *)machines[0])->stringValue() );
194     check_error(); check_memory();
195
196     // 'parameters:' section
197     value.cancelRedirection();
198     value = 0L;
199     value.setPrompt( NULL );
200     value.setInput( true );
201     par = &(fifo_mod->par("service_time"));
202     check_param(par, "service_time");
203     *par = value;
204
205     n = fifo_mod->params();
206     for(k=0;k<n;k++)
207        if(fifo_mod->par(k).isInput())
208           {fifo_mod->par(k).read();check_error();}
209
210     fifo_mod->setDisplayString(dispSUBMOD, "p=164,78;i=queue" );
211
212     // build function call:
213     fifo_mod->buildInside();
214     machines.clear();
215
216     // sink
217     modtype = findModuleType( "FF2Sink" );
218     check_modtype( modtype, "FF2Sink" );
219     cModule *sink_mod;
220
221     // an empty actual machine list for the next module
222     par = new cPar();
223     *par = mod->machinePar("default");
224     machines.add( par );
225     check_error(); check_memory();
226
227     // module creation:
228     islocal = simulation.netInterface()==NULL ||
229               simulation.netInterface()->isLocalMachineIn( machines );
230     sink_mod = modtype->create( "sink", mod, islocal);
231     check_error(); check_memory();
232
233     // set machine list:
234     sink_mod->setMachinePar( "default", ((cPar *)machines[0])->stringValue() );
235     check_error(); check_memory();
236
237     n = sink_mod->params();
238     for(k=0;k<n;k++)
239        if(sink_mod->par(k).isInput())
240           {sink_mod->par(k).read();check_error();}
241
242     sink_mod->setDisplayString(dispSUBMOD, "p=244,78;i=sink" );
243
244     // build function call:
245     sink_mod->buildInside();
246     machines.clear();
247
248     // Connections:
249     cLinkType *link_p;
250     cPar *delay_p, *error_p, *datarate_p;
251     int gateL, gateR;
252     long mod_nr_L, mod_nr_R, gate_nr_L, gate_nr_R;
253
254     do_this_block = true; // no "if" condition
255     if (do_this_block) // "if" in NED
256     {
257     gateL = gen_mod->findGate( "out" );
258     check_gate( gateL, "gen", "out" );
259
260     gateR = fifo_mod->findGate( "in" );
261     check_gate( gateR, "fifo", "in" );
262
263     connect (gen_mod, gateL,
264              NULL,
265              fifo_mod, gateR)
;
266
267     check_error(); check_memory();
268     } // end-if
269
270
271     do_this_block = true; // no "if" condition
272     if (do_this_block) // "if" in NED
273     {
274     gateL = fifo_mod->findGate( "out" );
275     check_gate( gateL, "fifo", "out" );
276
277     gateR = sink_mod->findGate( "in" );
278     check_gate( gateR, "sink", "in" );
279
280     connect (fifo_mod, gateL,
281              NULL,
282              sink_mod, gateR)
;
283
284     check_error(); check_memory();
285     } // end-if
286
287     mod->checkInternalConnections();
288     check_error(); check_memory();
289 }
290
291 class fifonet1 : public cNetworkType
292 {
293   public:
294     fifonet1(const char *name) : cNetworkType(name) {}
295     fifonet1(const fifonet1& n)  {setName(n.name());operator=(n);}
296     virtual void setupNetwork();
297 };
298
299 Define_Network( fifonet1 );
300
301 void fifonet1::setupNetwork()
302 {
303
304     // temporary variables:
305     cPar value, *par;
306     cPar::ExprElem *expr_tab; int k;
307     cFunctionType *functype;
308     const char *type_name;
309     char b1[64], b2[64];
310     cArray machines;
311     bool islocal, do_this_block;
312     int n;
313
314     // an empty actual machine list for the next module
315     par = new cPar();
316     *par = ev.getPhysicalMachineFor("default");
317     machines.add( par );
318     check_error(); check_memory();
319
320     // system module creation
321     cModuleType *modtype;
322     modtype = findModuleType( "FifoNet1" );
323     check_modtype( modtype, "FifoNet1" );
324     cModule *fifonet1_mod;
325
326     // module creation:
327     islocal = simulation.netInterface()==NULL ||
328               simulation.netInterface()->isLocalMachineIn( machines );
329     if (!islocal)
330         throw new cException("Local machine `%s' is not among machines specified for this network",
331                   simulation.netInterface()->localhost())
;
332     fifonet1_mod = modtype->create( "fifonet1", NULL, islocal);
333     check_error(); check_memory();
334
335     // set machine list:
336     fifonet1_mod->setMachinePar( "default", ev.getPhysicalMachineFor("default") );
337     check_error(); check_memory();
338
339     n = fifonet1_mod->params();
340     for(k=0;k<n;k++)
341        if(fifonet1_mod->par(k).isInput())
342           {fifonet1_mod->par(k).read();check_error();}
343
344     // build function call:
345     fifonet1_mod->buildInside();
346     machines.clear();
347
348     check_error(); check_memory();
349 }
350
351