This repository has been archived by the owner on Apr 3, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathclasses.py
56 lines (44 loc) · 1.6 KB
/
classes.py
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
import global_vars
import classes
import functions
#### Classes ####
class Node():
"""Class for the node"""
def __init__(self):
self.current_row = -1
self.current_col = -1
self.heading = ''
#self.channel = Channel(str(1001))
self.packets_sent = 0
self.packets_received = 0
self.log = []
class Mote():
"""
Class for the mote sensors
INPUT: mote identifier, it's row in MOTES_ARRAY, it's column in MOTES_ARRAY
"""
def __init__(self, moteID, row, column):
self.moteID = 'mote%s' % moteID
self.locationR = int(row) #row in the MOTES_ARRAY
self.locationC = int(column) #column in the MOTES_ARRAY
self.payload = False #no payload to send
self.echo = True #initially echo must be sent
#real coordinates of the mote
#Index location : upper left corner
self.positionX = (self.locationC +1) * 100
self.positionY = (self.locationR + 1) * 100
self.gateway = False
self.neighbors = [] #lookup table
self.parent = str() #where the mote forwards it's data
#self.channel = Channel(moteID)
self.cca_once = 0 ##
#0: cca has not been set for this random node entry ##
#1: cca has been set for this random node entry ##
self.packets_sent = 0
self.packets_received = 0
class Channel():
"""Class for the channels in the network"""
def __init__(self, channelID):
self.channelID = 'channel%d' % channelID
self.occupied = False
self.release_time = 0