-
-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathl1node.py
More file actions
64 lines (50 loc) · 1.83 KB
/
l1node.py
File metadata and controls
64 lines (50 loc) · 1.83 KB
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
import sys
sys.path.append("../")
from utilities import *
class L1Node():
"A class to hold L1Node"
def __init__(self, position: Vector, radius: float, label: str = None):
#super(self.Node).__init__()
self.label = label
self.position = position
self.radius = radius
self.circuits = []
self._failed = False
def get_circuits(self):
return self.circuits
def failNode(self):
self._failed = True
#TODO this is duplicate now as the get_circuits_l1_node return the same
for circuit in self.circuits:
circuit.failCircuit()
def unfailNode(self):
self._failed = False
#TODO this is duplicate now as the get_circuits_l1_node return the same
for circuit in self.circuits:
circuit.unfailCircuit()
def __repr__(self) -> str:
return self.label
def get_x(self) -> float:
"""Returns the x coordinate of the node."""
return self.position[0]
def get_y(self) -> float:
"""Returns the y coordinate of the node."""
return self.position[1]
def get_position(self) -> Vector:
"""Returns the y coordinate of the node."""
return self.position
def get_radius(self) -> float:
"""Returns the radius of the node."""
return self.radius
def get_circuits(self) -> list:
"""Returns all circuits"""
return self.circuits
def set_x(self, value: float):
"""Sets the x coordinate of the node to the specified value."""
self.position[0] = value
def set_y(self, value):
"""Sets the y coordinate of the node to the specified value."""
self.position[1] = value
def set_position(self, value: Vector):
"""Sets the position of the node to the specified value."""
self.position = value