updated grpc node positions to use floats, avoids needing to deal with int conversions
This commit is contained in:
parent
9c302e8bc6
commit
819954a695
6 changed files with 12 additions and 33 deletions
|
@ -183,8 +183,7 @@ class CoreClient:
|
||||||
)
|
)
|
||||||
|
|
||||||
def handle_exception_event(self, event):
|
def handle_exception_event(self, event):
|
||||||
print(event)
|
logging.info("exception event: %s", event)
|
||||||
print(event.node_id)
|
|
||||||
self.app.statusbar.core_alarms.append(event)
|
self.app.statusbar.core_alarms.append(event)
|
||||||
|
|
||||||
def join_session(self, session_id, query_location=True):
|
def join_session(self, session_id, query_location=True):
|
||||||
|
|
|
@ -616,10 +616,7 @@ class CanvasGraph(tk.Canvas):
|
||||||
if self.selected is None or self.selected in self.shapes:
|
if self.selected is None or self.selected in self.shapes:
|
||||||
actual_x, actual_y = self.get_actual_coords(x, y)
|
actual_x, actual_y = self.get_actual_coords(x, y)
|
||||||
core_node = self.core.create_node(
|
core_node = self.core.create_node(
|
||||||
int(actual_x),
|
actual_x, actual_y, self.node_draw.node_type, self.node_draw.model
|
||||||
int(actual_y),
|
|
||||||
self.node_draw.node_type,
|
|
||||||
self.node_draw.model,
|
|
||||||
)
|
)
|
||||||
node = CanvasNode(self.master, x, y, core_node, self.node_draw.image)
|
node = CanvasNode(self.master, x, y, core_node, self.node_draw.image)
|
||||||
self.core.canvas_nodes[core_node.id] = node
|
self.core.canvas_nodes[core_node.id] = node
|
||||||
|
|
|
@ -140,8 +140,8 @@ class CanvasNode:
|
||||||
|
|
||||||
# set actual coords for node and update core is running
|
# set actual coords for node and update core is running
|
||||||
real_x, real_y = self.canvas.get_actual_coords(x, y)
|
real_x, real_y = self.canvas.get_actual_coords(x, y)
|
||||||
self.core_node.position.x = int(real_x)
|
self.core_node.position.x = real_x
|
||||||
self.core_node.position.y = int(real_y)
|
self.core_node.position.y = real_y
|
||||||
if self.app.core.is_runtime() and update:
|
if self.app.core.is_runtime() and update:
|
||||||
self.app.core.edit_node(self.core_node)
|
self.app.core.edit_node(self.core_node)
|
||||||
|
|
||||||
|
@ -164,11 +164,6 @@ class CanvasNode:
|
||||||
else:
|
else:
|
||||||
self.show_config()
|
self.show_config()
|
||||||
|
|
||||||
def update_coords(self):
|
|
||||||
x, y = self.canvas.coords(self.id)
|
|
||||||
self.core_node.position.x = int(x)
|
|
||||||
self.core_node.position.y = int(y)
|
|
||||||
|
|
||||||
def create_context(self):
|
def create_context(self):
|
||||||
is_wlan = self.core_node.type == NodeType.WIRELESS_LAN
|
is_wlan = self.core_node.type == NodeType.WIRELESS_LAN
|
||||||
is_emane = self.core_node.type == NodeType.EMANE
|
is_emane = self.core_node.type == NodeType.EMANE
|
||||||
|
|
|
@ -489,13 +489,7 @@ class CoreGrpcServer(core_pb2_grpc.CoreApiServicer):
|
||||||
:return: node event that contains node id, name, model, position, and services
|
:return: node event that contains node id, name, model, position, and services
|
||||||
:rtype: core.api.grpc.core_pb2.NodeEvent
|
:rtype: core.api.grpc.core_pb2.NodeEvent
|
||||||
"""
|
"""
|
||||||
x = None
|
position = core_pb2.Position(x=event.x_position, y=event.y_position)
|
||||||
if event.x_position is not None:
|
|
||||||
x = int(event.x_position)
|
|
||||||
y = None
|
|
||||||
if event.y_position is not None:
|
|
||||||
y = int(event.y_position)
|
|
||||||
position = core_pb2.Position(x=x, y=y)
|
|
||||||
services = event.services or ""
|
services = event.services or ""
|
||||||
services = services.split("|")
|
services = services.split("|")
|
||||||
node_proto = core_pb2.Node(
|
node_proto = core_pb2.Node(
|
||||||
|
|
|
@ -117,14 +117,8 @@ class NodeElement:
|
||||||
|
|
||||||
def add_position(self):
|
def add_position(self):
|
||||||
x = self.node.position.x
|
x = self.node.position.x
|
||||||
if x is not None:
|
|
||||||
x = int(x)
|
|
||||||
y = self.node.position.y
|
y = self.node.position.y
|
||||||
if y is not None:
|
|
||||||
y = int(y)
|
|
||||||
z = self.node.position.z
|
z = self.node.position.z
|
||||||
if z is not None:
|
|
||||||
z = int(z)
|
|
||||||
lat, lon, alt = None, None, None
|
lat, lon, alt = None, None, None
|
||||||
if x is not None and y is not None:
|
if x is not None and y is not None:
|
||||||
lat, lon, alt = self.session.location.getgeo(x, y, z)
|
lat, lon, alt = self.session.location.getgeo(x, y, z)
|
||||||
|
@ -751,8 +745,8 @@ class CoreXmlReader:
|
||||||
|
|
||||||
position_element = device_element.find("position")
|
position_element = device_element.find("position")
|
||||||
if position_element is not None:
|
if position_element is not None:
|
||||||
x = get_int(position_element, "x")
|
x = get_float(position_element, "x")
|
||||||
y = get_int(position_element, "y")
|
y = get_float(position_element, "y")
|
||||||
if all([x, y]):
|
if all([x, y]):
|
||||||
options.set_position(x, y)
|
options.set_position(x, y)
|
||||||
|
|
||||||
|
@ -773,8 +767,8 @@ class CoreXmlReader:
|
||||||
|
|
||||||
position_element = network_element.find("position")
|
position_element = network_element.find("position")
|
||||||
if position_element is not None:
|
if position_element is not None:
|
||||||
x = get_int(position_element, "x")
|
x = get_float(position_element, "x")
|
||||||
y = get_int(position_element, "y")
|
y = get_float(position_element, "y")
|
||||||
if all([x, y]):
|
if all([x, y]):
|
||||||
options.set_position(x, y)
|
options.set_position(x, y)
|
||||||
|
|
||||||
|
|
|
@ -949,9 +949,9 @@ message SessionLocation {
|
||||||
}
|
}
|
||||||
|
|
||||||
message Position {
|
message Position {
|
||||||
int32 x = 1;
|
float x = 1;
|
||||||
int32 y = 2;
|
float y = 2;
|
||||||
int32 z = 3;
|
float z = 3;
|
||||||
float lat = 4;
|
float lat = 4;
|
||||||
float lon = 5;
|
float lon = 5;
|
||||||
float alt = 6;
|
float alt = 6;
|
||||||
|
|
Loading…
Reference in a new issue