fixing mobility working in python2/3 due to using __cmp__ and node updates not being ints
This commit is contained in:
parent
e0dcb194cc
commit
e7d12b9746
1 changed files with 18 additions and 13 deletions
|
@ -9,7 +9,7 @@ import os
|
||||||
import threading
|
import threading
|
||||||
import time
|
import time
|
||||||
from builtins import int
|
from builtins import int
|
||||||
from past.builtins import cmp
|
from functools import total_ordering
|
||||||
|
|
||||||
from core import utils
|
from core import utils
|
||||||
from core.config import ConfigGroup
|
from core.config import ConfigGroup
|
||||||
|
@ -561,6 +561,7 @@ class BasicRangeModel(WirelessModel):
|
||||||
return all_links
|
return all_links
|
||||||
|
|
||||||
|
|
||||||
|
@total_ordering
|
||||||
class WayPoint(object):
|
class WayPoint(object):
|
||||||
"""
|
"""
|
||||||
Maintains information regarding waypoints.
|
Maintains information regarding waypoints.
|
||||||
|
@ -580,18 +581,17 @@ class WayPoint(object):
|
||||||
self.coords = coords
|
self.coords = coords
|
||||||
self.speed = speed
|
self.speed = speed
|
||||||
|
|
||||||
def __cmp__(self, other):
|
def __eq__(self, other):
|
||||||
"""
|
return (self.time, self.nodenum) == (other.time, other.nodedum)
|
||||||
Custom comparison method for waypoints.
|
|
||||||
|
|
||||||
:param WayPoint other: waypoint to compare to
|
def __ne__(self, other):
|
||||||
:return: the comparison result against the other waypoint
|
return not self == other
|
||||||
:rtype: int
|
|
||||||
"""
|
def __lt__(self, other):
|
||||||
tmp = cmp(self.time, other.time)
|
result = self.time < other.time
|
||||||
if tmp == 0:
|
if result:
|
||||||
tmp = cmp(self.nodenum, other.nodenum)
|
result = self.nodenum < other.nodenum
|
||||||
return tmp
|
return result
|
||||||
|
|
||||||
|
|
||||||
class WayPointMobility(WirelessModel):
|
class WayPointMobility(WirelessModel):
|
||||||
|
@ -836,7 +836,12 @@ class WayPointMobility(WirelessModel):
|
||||||
:param z: z position
|
:param z: z position
|
||||||
:return: nothing
|
:return: nothing
|
||||||
"""
|
"""
|
||||||
# this would cause PyCoreNetIf.poshook() callback (range calculation)
|
if x is not None:
|
||||||
|
x = int(x)
|
||||||
|
if y is not None:
|
||||||
|
y = int(y)
|
||||||
|
if z is not None:
|
||||||
|
z = int(z)
|
||||||
node.position.set(x, y, z)
|
node.position.set(x, y, z)
|
||||||
node_data = node.data(message_type=0)
|
node_data = node.data(message_type=0)
|
||||||
self.session.broadcast_node(node_data)
|
self.session.broadcast_node(node_data)
|
||||||
|
|
Loading…
Reference in a new issue