sources:
generator.cpp (709 bytes)
generator.h (417 bytes)
generator_n.cpp (4.0k)
lbs_i.cpp (2.6k)
lbs_i.h (430 bytes)
lbs_i_n.cpp (4.1k)
lbs_ii.cpp (3.3k)
lbs_ii.h (439 bytes)
lbs_ii_n.cpp (4.1k)
minimumselector.cpp (1.7k)
minimumselector.h (359 bytes)
minimumselector_n.cpp (4.1k)
randomselector.cpp (454 bytes)
randomselector.h (266 bytes)
randomselector_n.cpp (4.1k)
server.cpp (1.6k)
server.h (508 bytes)
server_n.cpp (4.0k)
servicenet_n.cpp (13.6k)
sink.cpp (1.3k)
sink.h (495 bytes)
sink_n.cpp (3.9k)


website:
more info here


screenshot:
studies/performance/Performance-Code5/servicenet_n.cpp
download file

  1 //-----------------------------------------
  2 //
  3 // Generated by NEDC version 2.3b2
  4 // date: Sat Jun 21 13:41:37 2003
  5 //
  6 // Input file: generator.ned
  7 // Output file: generator_n.cpp
  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: servicenet.ned
 81 //--------------------------------------------
 82
 83 ModuleInterface( Selector )
 84     Machine( default )
 85     Parameter( server_count, ParType_Numeric )
 86     Gate( out[], GateDir_Output )
 87     Gate( in, GateDir_Input )
 88 EndInterface
 89 Register_ModuleInterface( Selector )
 90
 91 // class Selector : public cSimpleModule
 92 // {
 93 // Module_Class_Members(Selector,cSimpleModule,8192)
 94 // virtual void activity();
 95 // // Add you own member functions here!
 96 // };
 97 //
 98 // Define_Module( Selector )
 99 //
100 // void Selector::activity()
101 // {
102 // // Put code for simple module activity here!
103 // }
104 //
105
106 ModuleInterface( ServiceNet )
107     Machine( default )
108     Parameter( server_count, ParType_Numeric ParType_Const )
109     Parameter( selector_type, ParType_String )
110     Parameter( generator_rate, ParType_Numeric ParType_Const )
111     Parameter( generator_rg, ParType_Numeric ParType_Const )
112     Parameter( sample_count, ParType_Numeric ParType_Const )
113 EndInterface
114 Register_ModuleInterface( ServiceNet )
115
116 class ServiceNet : public cCompoundModule {
117   public:
118     ServiceNet(const char *name, cModule *parentmod) :
119       cCompoundModule(name, parentmod) {}
120   protected:
121     virtual void doBuildInside();
122 };
123
124 Define_Module( ServiceNet );
125
126 void ServiceNet::doBuildInside()
127 {
128     cModule *mod = this;
129     // temporary variables:
130     cPar value, *par;
131     cPar::ExprElem *expr_tab; int k;
132     cFunctionType *functype;
133     const char *type_name;
134     char b1[64], b2[64];
135     cArray machines;
136     bool islocal, do_this_block;
137     int n;
138
139     // const parameters:
140     // Submodules:
141     cModuleType *modtype = NULL;
142     long sub_nr = 0;
143     long sub_i = 0;
144
145     // server
146     modtype = findModuleType( "Server" );
147     check_modtype( modtype, "Server" );
148     sub_nr = mod->par( "server_count" );
149     check_module_count(sub_nr,"server","ServiceNet");
150     cModule **server_mod = new cModule *[sub_nr];
151
152     for (sub_i=0; sub_i<sub_nr; sub_i++)
153     {
154         // an empty actual machine list for the next module
155         par = new cPar();
156         *par = mod->machinePar("default");
157         machines.add( par );
158         check_error(); check_memory();
159
160         // module creation:
161         islocal = simulation.netInterface()==NULL ||
162                   simulation.netInterface()->isLocalMachineIn( machines );
163         server_mod[sub_i] = modtype->create( "server", mod, islocal);
164         check_error(); check_memory();
165
166         server_mod[sub_i]->setIndex(sub_i, sub_nr);
167
168         // set machine list:
169         server_mod[sub_i]->setMachinePar( "default", ((cPar *)machines[0])->stringValue() );
170         check_error(); check_memory();
171
172         // 'parameters:' section
173         par = &(server_mod[sub_i]->par("address"));
174         check_param(par, "address");
175         *par = (long)sub_i;
176
177         n = server_mod[sub_i]->params();
178         for(k=0;k<n;k++)
179            if(server_mod[sub_i]->par(k).isInput())
180               {server_mod[sub_i]->par(k).read();check_error();}
181
182         // build function call:
183         server_mod[sub_i]->buildInside();
184     }
185     machines.clear();
186
187     // selector
188     par = &mod->par("selector_type");
189     check_param(par,"selector_type");
190     type_name = (const char *)par;
191     type_name = mod->par("selector_type");
192     modtype = findModuleType( type_name );
193     check_modtype( modtype, type_name );
194     cModule *selector_mod;
195
196     // an empty actual machine list for the next module
197     par = new cPar();
198     *par = mod->machinePar("default");
199     machines.add( par );
200     check_error(); check_memory();
201
202     // module creation:
203     islocal = simulation.netInterface()==NULL ||
204               simulation.netInterface()->isLocalMachineIn( machines );
205     selector_mod = modtype->create( "selector", mod, islocal);
206     check_error(); check_memory();
207
208     // set machine list:
209     selector_mod->setMachinePar( "default", ((cPar *)machines[0])->stringValue() );
210     check_error(); check_memory();
211
212     // 'parameters:' section
213     par = &(selector_mod->par("server_count"));
214     check_param(par, "server_count");
215     *par = mod->par( "server_count" );
216
217     n = selector_mod->params();
218     for(k=0;k<n;k++)
219        if(selector_mod->par(k).isInput())
220           {selector_mod->par(k).read();check_error();}
221
222     // 'gatesizes:' section
223     n = mod->par( "server_count" );
224     check_gate_count( n, "selector","out","ServiceNet");
225     selector_mod->setGateSize("out", n );
226
227     // build function call:
228     selector_mod->buildInside();
229     machines.clear();
230
231     // sink
232     modtype = findModuleType( "Sink" );
233     check_modtype( modtype, "Sink" );
234     cModule *sink_mod;
235
236     // an empty actual machine list for the next module
237     par = new cPar();
238     *par = mod->machinePar("default");
239     machines.add( par );
240     check_error(); check_memory();
241
242     // module creation:
243     islocal = simulation.netInterface()==NULL ||
244               simulation.netInterface()->isLocalMachineIn( machines );
245     sink_mod = modtype->create( "sink", mod, islocal);
246     check_error(); check_memory();
247
248     // set machine list:
249     sink_mod->setMachinePar( "default", ((cPar *)machines[0])->stringValue() );
250     check_error(); check_memory();
251
252     // 'parameters:' section
253     par = &(sink_mod->par("sample_count"));
254     check_param(par, "sample_count");
255     *par = mod->par( "sample_count" );
256
257     n = sink_mod->params();
258     for(k=0;k<n;k++)
259        if(sink_mod->par(k).isInput())
260           {sink_mod->par(k).read();check_error();}
261
262     // 'gatesizes:' section
263     n = mod->par( "server_count" );
264     check_gate_count( n, "sink","in","ServiceNet");
265     sink_mod->setGateSize("in", n );
266
267     // build function call:
268     sink_mod->buildInside();
269     machines.clear();
270
271     // generator
272     modtype = findModuleType( "Generator" );
273     check_modtype( modtype, "Generator" );
274     cModule *generator_mod;
275
276     // an empty actual machine list for the next module
277     par = new cPar();
278     *par = mod->machinePar("default");
279     machines.add( par );
280     check_error(); check_memory();
281
282     // module creation:
283     islocal = simulation.netInterface()==NULL ||
284               simulation.netInterface()->isLocalMachineIn( machines );
285     generator_mod = modtype->create( "generator", mod, islocal);
286     check_error(); check_memory();
287
288     // set machine list:
289     generator_mod->setMachinePar( "default", ((cPar *)machines[0])->stringValue() );
290     check_error(); check_memory();
291
292     // 'parameters:' section
293     par = &(generator_mod->par("rate"));
294     check_param(par, "rate");
295     *par = mod->par( "generator_rate" );
296
297     par = &(generator_mod->par("random_generator"));
298     check_param(par, "random_generator");
299     *par = mod->par( "generator_rg" );
300
301     n = generator_mod->params();
302     for(k=0;k<n;k++)
303        if(generator_mod->par(k).isInput())
304           {generator_mod->par(k).read();check_error();}
305
306     // build function call:
307     generator_mod->buildInside();
308     machines.clear();
309
310     // Connections:
311     cLinkType *link_p;
312     cPar *delay_p, *error_p, *datarate_p;
313     int gateL, gateR;
314     long mod_nr_L, mod_nr_R, gate_nr_L, gate_nr_R;
315     {
316         // for i loop:
317         long i_index;
318
319         long i_begin = 0;
320         expr_tab = new cPar::ExprElem[3]; k=0;
321         expr_tab[k++] = mod->par( "server_count" );
322         expr_tab[k++] = 1;
323         expr_tab[k++] = '-';
324         value.cancelRedirection();
325         value.setDoubleValue(expr_tab,k);
326         long i_end = value;
327         check_loop_bounds(i_begin, i_end, "ServiceNet");
328         for (i_index=i_begin; i_index<=i_end; i_index++)
329         {
330
331             do_this_block = true; // no "if" condition
332             if (do_this_block) // "if" in NED
333             {
334             gate_nr_L = i_index;
335             gateL = selector_mod->findGate( "out", gate_nr_L );
336             check_gate( gateL, "selector", indexedname(b1,"out",gate_nr_L) );
337
338             mod_nr_R = i_index;
339             check_module_index(mod_nr_R,server_mod,"server", "ServiceNet");
340             gateR = server_mod[mod_nr_R]->findGate( "in" );
341             check_gate( gateR, "server", "in" );
342
343             connect (selector_mod, gateL,
344                      NULL,
345                      server_mod[mod_nr_R], gateR)
;
346
347             check_error(); check_memory();
348             } // end-if
349
350
351             do_this_block = true; // no "if" condition
352             if (do_this_block) // "if" in NED
353             {
354             mod_nr_L = i_index;
355             check_module_index(mod_nr_L,server_mod,"server", "ServiceNet");
356             gateL = server_mod[mod_nr_L]->findGate( "out" );
357             check_gate( gateL, "server", "out" );
358
359             gate_nr_R = i_index;
360             gateR = sink_mod->findGate( "in", gate_nr_R );
361             check_gate( gateR, "sink", indexedname(b1,"in",gate_nr_R) );
362
363             connect (server_mod[mod_nr_L], gateL,
364                      NULL,
365                      sink_mod, gateR)
;
366
367             check_error(); check_memory();
368             } // end-if
369
370         } // end for i
371
372     }
373
374
375     do_this_block = true; // no "if" condition
376     if (do_this_block) // "if" in NED
377     {
378     gateL = generator_mod->findGate( "out" );
379     check_gate( gateL, "generator", "out" );
380
381     gateR = selector_mod->findGate( "in" );
382     check_gate( gateR, "selector", "in" );
383
384     connect (generator_mod, gateL,
385              NULL,
386              selector_mod, gateR)
;
387
388     check_error(); check_memory();
389     } // end-if
390
391     mod->checkInternalConnections();
392     delete[] server_mod;
393     check_error(); check_memory();
394 }
395
396 class servicenet : public cNetworkType {
397   public:
398     servicenet(const char *name) : cNetworkType(name) {}
399     servicenet(const servicenet& n)  {setName(n.name());operator=(n);}
400     virtual void setupNetwork();
401 };
402
403 Define_Network( servicenet );
404
405 void servicenet::setupNetwork()
406 {
407
408     // temporary variables:
409     cPar value, *par;
410     cPar::ExprElem *expr_tab; int k;
411     cFunctionType *functype;
412     const char *type_name;
413     char b1[64], b2[64];
414     cArray machines;
415     bool islocal, do_this_block;
416     int n;
417
418     // an empty actual machine list for the next module
419     par = new cPar();
420     *par = ev.getPhysicalMachineFor("default");
421     machines.add( par );
422     check_error(); check_memory();
423
424     // system module creation
425     cModuleType *modtype;
426     modtype = findModuleType( "ServiceNet" );
427     check_modtype( modtype, "ServiceNet" );
428     cModule *servicenet_mod;
429
430     // module creation:
431     islocal = simulation.netInterface()==NULL ||
432               simulation.netInterface()->isLocalMachineIn( machines );
433     if (!islocal)
434         throw new cException("Local machine `%s' is not among machines specified for this network",
435                   simulation.netInterface()->localhost())
;
436     servicenet_mod = modtype->create( "servicenet", NULL, islocal);
437     check_error(); check_memory();
438
439     // set machine list:
440     servicenet_mod->setMachinePar( "default", ev.getPhysicalMachineFor("default") );
441     check_error(); check_memory();
442
443     n = servicenet_mod->params();
444     for(k=0;k<n;k++)
445        if(servicenet_mod->par(k).isInput())
446           {servicenet_mod->par(k).read();check_error();}
447
448     // build function call:
449     servicenet_mod->buildInside();
450     machines.clear();
451
452     check_error(); check_memory();
453 }
454
455
456