0% found this document useful (0 votes)
93 views5 pages

Node N

code for nod_n.cc

Uploaded by

Mohamed Taha
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
93 views5 pages

Node N

code for nod_n.cc

Uploaded by

Mohamed Taha
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 5

node_n.cc - Free Open Source Codes - CodeForge.

com Page 1 of 5

Source Codes Point Help Upload Login Sign up | Favorite Language

Home Source Code PEGASIS Protocol in Omnet++ node_n.cc

node_n.cc ( File view )


From PEGASIS Protocol in Omnet++
DescriptionSource Code of Protocols: PEGASIS Protocol in Omnet++, PEGASIS Protocol in Omnet++, PEGASIS Protocol in Omnet++...

By fati_2014 2015-03-10 View(s)1 Download(s)0 Point(s) 1 Rate0.0

1
2 // This code is done by Nailah Madi
3 // Copyright (C) 2011 Nailah Madi
4 //
5 // Nailah AlMadi
6 // Computer Science Dept.
7 // North Dakota State University
8 //
9 // [email protected]
10 //
11 //
12 // This program is free software: you can redistribute it and/or modify
13 // it under the terms of the GNU General Public License as published by
14 // the Free Software Foundation, either version 3 of the License, any
15 // later version.
16 //
17 // This program is distributed in the hope that it will be useful,
18 // but WITHOUT ANY WARRANTY; without even the implied warranty of
19 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 // GNU General Public License for more details.
21 //
22 // You should have received a copy of the GNU General Public License
23 // along with this program. If not, see <http://www.gnu.org/licenses/>.
24 //
25
26
27
//-----------------------------------------
28
//
29
// Generated by nedtool, version 3.3
30
// date: Sun Dec 28 22:19:10 2008
31
//
32
//-----------------------------------------
33
34
35
#include <math.h>
36
#include "omnetpp.h"
37
38
// NEDC version check
39
#define NEDC_VERSION 0x0303
40
#if (NEDC_VERSION!=OMNETPP_VERSION)
# error Version mismatch! Probably this file was generated by an earlier version of nedc: 'make clean' should help.
41
#endif
42
43
// Disable warnings about unused variables. For MSVC and BC only:
44
// GCC has no way to turn on its -Wunused option in a source file :(
45
#ifdef _MSC_VER
46
# pragma warning(disable:4101)
47
48 #endif
49 #ifdef __BORLANDC__
50 # pragma warn -waus
51 # pragma warn -wuse
52 #endif
53
54 static cModuleType *_getModuleType(const char *modname)
55 {
56
57 cModuleType *modtype = findModuleType(modname);
58 if (!modtype)
throw new cRuntimeError("Module type definition %s not found (Define_Module() missing from C++ code?)",
modname); 0.0 1 point PEGASIS Protocol in Omnet++.ra Favorite Share
Please input your comme Submit
59

http://www.codeforge.com/read/251393/node_n.cc__html 11/1/2017
node_n.cc - Free Open Source Codes - CodeForge.com Page 2 of 5

60 return modtype;
61
62
}
63
64
static void _checkModuleVectorSize(int vectorsize, const char *mod)
65
{
66
67
68 if (vectorsize<0)
69 throw new cRuntimeError("Negative module vector size %s[%d]", mod, vectorsize);
70
71 }
72
73 static void _readModuleParameters(cModule *mod)
74 {
75
76 int n = mod->params();
77 for (int k=0; k<n; k++)
78 if (mod->par(k).isInput())
79 mod->par(k).read();
80
81 }
82
83 static int _checkModuleIndex(int index, int vectorsize, const char *modname)
84 {
85
if (index<0 || index>=vectorsize)
86 throw new cRuntimeError("Submodule index %s[%d] out of range, sizeof(%s) is %d", modname, index, modname,
87 vectorsize);
88 return index;
89
90 }
91
92 static cGate *_checkGate(cModule *mod, const char *gatename)
93 {
94
95 cGate *g = mod->gate(gatename);
96 if (!g)
97 throw new cRuntimeError("%s has no gate named %s",mod->fullPath().c_str(), gatename);
98 return g;
99
100 }
101
102 static cGate *_checkGate(cModule *mod, const char *gatename, int gateindex)
103 {
104
105 cGate *g = mod->gate(gatename, gateindex);
106 if (!g)
107 throw new cRuntimeError("%s has no gate %s[%d]",mod->fullPath().c_str(), gatename, gateindex);
108 return g;
109
110 }
111
112 static cGate *_getFirstUnusedParentModGate(cModule *mod, const char *gatename)
113 {
114
115 int baseId = mod->findGate(gatename);
116 if (baseId<0)
117 throw new cRuntimeError("%s has no %s[] gate",mod->fullPath().c_str(), gatename);
118 int n = mod->gate(baseId)->size();
119 for (int i=0; i<n; i++)
120 if (!mod->gate(baseId+i)->isConnectedInside())
return mod->gate(baseId+i);
121 throw new cRuntimeError("%s[] gates are all connected, no gate left for `++' operator",mod->fullPath().c_str(),
122 gatename);
123
124 }
125
126 static cGate *_getFirstUnusedSubmodGate(cModule *mod, const char *gatename)
127 {
128
129 int baseId = mod->findGate(gatename);
130 if (baseId<0)
131 throw new cRuntimeError("%s has no %s[] gate",mod->fullPath().c_str(), gatename);
132 int n = mod->gate(baseId)->size();
0.0 1 point PEGASIS Protocol in Omnet++.ra Favorite Share
133 input your comme Submit
Please

http://www.codeforge.com/read/251393/node_n.cc__html 11/1/2017
node_n.cc - Free Open Source Codes - CodeForge.com Page 3 of 5

134 for (int i=0; i<n; i++)


135 if (!mod->gate(baseId+i)->isConnectedOutside())
136 return mod->gate(baseId+i);
137 int newBaseId = mod->setGateSize(gatename,n+1);
138 return mod->gate(newBaseId+n);
139
140 }
141
142 static cFunctionType *_getFunction(const char *funcname, int argcount)
143 {
144
145 cFunctionType *functype = findFunction(funcname,argcount);
146 if (!functype)
147 throw new cRuntimeError("Function %s with %d args not found", funcname, argcount);
148 return functype;
149
150 }
151
152 static cChannel *_createChannel(const char *channeltypename)
153 {
154
155
cChannelType *channeltype = findChannelType(channeltypename);
156
if (!channeltype)
157
throw new cRuntimeError("Channel type %s not found", channeltypename);
158
cChannel *channel = channeltype->create("channel");
159
return channel;
160
161
}
162
163
static cChannel *_createNonTypedBasicChannel(double delay, double error, double datarate)
164
{
165
166
cBasicChannel *channel = new cBasicChannel("channel");
167
if (delay!=0) channel->setDelay(delay);
168
if (error!=0) channel->setError(error);
169
if (datarate!=0) channel->setDatarate(datarate);
170
return channel;
171
172
}
173
174
static cXMLElement *_getXMLDocument(const char *fname, const char *pathexpr=NULL)
175
176 {

177 cXMLElement *node = ev.getXMLDocument(fname, pathexpr);


178 if (!node)
179 throw new cRuntimeError(!pathexpr ? "xmldoc(\"%s\"): element not found" : "xmldoc(\"%s\", \"%s\"): element not
180 found",fname,pathexpr);
181 return node;
182
183 }
184
185 ModuleInterface(Node)
186 // parameters:
187 Parameter(id, ParType_Numeric ParType_Const)
188 Parameter(energy, ParType_Numeric)
189 Parameter(xpos, ParType_Numeric ParType_Const)
190 Parameter(ypos, ParType_Numeric ParType_Const)
191 Parameter(leader, ParType_Numeric)
192 Parameter(inChain, ParType_Numeric)
193 // gates:
194 Gate(in, GateDir_Input)
195 Gate(out, GateDir_Output)
196 EndInterface
197
198 Register_ModuleInterface(Node)
199
200 //// Sample code:
201 // class Node : public cSimpleModule
202 // {
203
204 // Module_Class_Members(Node,cSimpleModule,16384)
205 // virtual void activity();
206 // // Add you own member functions here!
207 // 0.0 1 point PEGASIS Protocol in Omnet++.ra Favorite Share
Please input your comme Submit

http://www.codeforge.com/read/251393/node_n.cc__html 11/1/2017
node_n.cc - Free Open Source Codes - CodeForge.com Page 4 of 5

208
209 };
210 //
211 // Define_Module(Node);
212 //
213 // void Node::activity()
214 // {
215
216 // // Put code for simple module activity here!
//
}
//

Want complete source code? Download it here


Point(s): 1

Download

Sponsored links

Start Download - Merge & Convert Files into PDFs


View PDF w/ EasyPDFCombine - Free!

File list Tips: You can preview the content of files by clicking file names^_^

Name Size Date

bs.cc 8.31 kB 02-10-11 13:44


bs.h 522.00 B 23-05-08 00:35
bs.ned 164.00 B 27-04-08 00:51
bs_n.cc 5.82 kB 02-10-11 13:44
Copyright.txt 782.00 B 06-06-13 11:07
Makefile.vc 3.93 kB 29-12-08 01:19
msgs.msg 46.00 B 14-05-08 16:09
msgs_m.cc 8.36 kB 02-10-11 13:44
msgs_m.h 1.29 kB 29-12-08 01:19
node.cc 14.84 kB 02-10-11 13:44
node.h 1.83 kB 23-05-08 00:35
node.ned 162.00 B 12-11-08 19:26
node_n.cc 5.93 kB 02-10-11 13:44
node_n.obj 9.18 kB 29-12-08 01:19
omnetpp.ini 403.00 B 28-12-08 05:10
ReadMe.txt 782.00 B 06-06-13 11:07
Solar.h 429.00 B 23-05-08 00:34
Solar.ned 863.00 B 28-12-08 05:11
Solar_n.cc 8.44 kB 02-10-11 13:44
<PEGASIS> 0.00 B 02-10-11 00:52
...

1 2

Sponsored links

Start Download - Merge & Convert Files into PDFs


View PDF w/ EasyPDFCombine - Free!

0.0 1 point PEGASIS Protocol in Omnet++.ra Favorite Share


Please input your comme Submit Please input key words Search

http://www.codeforge.com/read/251393/node_n.cc__html 11/1/2017
node_n.cc - Free Open Source Codes - CodeForge.com Page 5 of 5

2014 CodeForge Dev Team All rights reserved. Email:[email protected]

Join us | Contact | Advertisement

Elapsed:40.698ms 5.199

0.0 1 point PEGASIS Protocol in Omnet++.ra Favorite Share


Please input your comme Submit

http://www.codeforge.com/read/251393/node_n.cc__html 11/1/2017

You might also like