-
Notifications
You must be signed in to change notification settings - Fork 0
/
Nanobot.cc
208 lines (170 loc) · 3.48 KB
/
Nanobot.cc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
/* -*- Mode: C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
* Copyright (c) 2017 Universität zu Lübeck [GEYER]
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation;
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* Author: Regine Geyer <[email protected]>
*/
#include "Nanobot.h"
namespace ns3 {
// TypeId Nanobot::GetTypeId (void)
// {
// static TypeId tid = TypeId ("ns3::Nanobot")
// .SetParent<Object> ()
// .AddConstructor<Nanobot> ()
// ;
// return tid;
// }
Nanobot::Nanobot ()
{
m_node = CreateObject<Node> ();
//enables mobility
MobilityHelper mobility;
mobility.Install (m_node);
m_length = 0.00001; //100nm
m_width = 0.00001; //100nm
m_stream_nb = 0;
m_shouldChange = false;
m_timeStep = Seconds (0.0);
vector<int> m_gateway_positions;
}
Nanobot::~Nanobot ()
{
}
bool
Nanobot::Compare (Ptr<Nanobot> v1, Ptr<Nanobot> v2)
{
if (v1->GetNanobotID () < v2->GetNanobotID ())
{
return true;
}
else
{
return false;
}
}
int
Nanobot::GetNanobotID ()
{
return m_nanobotID;
}
void
Nanobot::SetNanobotID (int value)
{
m_nanobotID = value;
}
double
Nanobot::GetLength ()
{
return m_length;
}
void
Nanobot::SetLength (double value)
{
if (value < 0)
{
value = 0;
}
m_length = value;
}
double
Nanobot::GetWidth ()
{
return m_width;
}
void
Nanobot::SetWidth (double value)
{
if (value < 0)
{
value = 0;
}
m_width = value;
}
void
Nanobot::SetStream (int value)
{
m_stream_nb = value;
}
int
Nanobot::GetStream ()
{
return m_stream_nb;
}
bool
Nanobot::GetShouldChange ()
{
return m_shouldChange;
}
void
Nanobot::SetShouldChange (bool value)
{
m_shouldChange = value;
}
ns3::Time
Nanobot::GetTimeStep ()
{
return m_timeStep;
}
void
Nanobot::SetTimeStep ()
{
m_timeStep = Simulator::Now ();
}
Vector
Nanobot::GetPosition ()
{
return m_node->GetObject<MobilityModel> ()->GetPosition ();
}
void
Nanobot::SetPosition (Vector value)
{
m_node->GetObject<MobilityModel> ()->SetPosition (value);
}
std::vector<int>
Nanobot::GetGatewayPositions()
{
return m_gateway_positions;
}
void
Nanobot::SetGatewayPositions(std::vector<int> val)
{
m_gateway_positions = val;
}
void Nanobot::Settissue_ID(std::vector<int> val)
{
m_tissue_ID = val;
}
vector<int> Nanobot::Gettissue_ID()
{
return m_tissue_ID;
}
void
Nanobot::InstallNanoNetDevice(Ptr<BVSChannel> channel)
{
Ptr<NanoNetDevice> device = CreateObject<NanoNetDevice> ();
device->SetAddress(Mac48Address::Allocate());
device->SetChannel(channel);
m_node->AddDevice(device);
m_nanoNetDevice = device;
}
Ptr<NetDevice> Nanobot::GetDevice()
{
return m_node->GetDevice(0);
}
Ptr<NanoNetDevice> Nanobot::GetNanoNetDevice()
{
return m_nanoNetDevice;
}
} // namespace ns3