fix get_locator_beacon
This commit is contained in:
parent
995f17c138
commit
d84226dc5c
3 changed files with 14 additions and 7 deletions
|
@ -284,9 +284,9 @@ class MeshNode(models.Model):
|
||||||
return False
|
return False
|
||||||
return dst_node.get_uplink()
|
return dst_node.get_uplink()
|
||||||
|
|
||||||
def get_locator_beacon(self):
|
def get_locator_xyz(self):
|
||||||
locator = RangeLocator.load()
|
locator = RangeLocator.load()
|
||||||
return locator.beacons.get(self.address, None)
|
return locator.get_xyz(self.address)
|
||||||
|
|
||||||
|
|
||||||
class MeshUplink(models.Model):
|
class MeshUplink(models.Model):
|
||||||
|
|
|
@ -110,13 +110,13 @@
|
||||||
Y={{ node.last_messages.CONFIG_POSITION.parsed.y_pos | cm_to_m }}
|
Y={{ node.last_messages.CONFIG_POSITION.parsed.y_pos | cm_to_m }}
|
||||||
Z={{ node.last_messages.CONFIG_POSITION.parsed.z_pos | cm_to_m }}
|
Z={{ node.last_messages.CONFIG_POSITION.parsed.z_pos | cm_to_m }}
|
||||||
</p>
|
</p>
|
||||||
{% with locator_beacon=node.get_locator_beacon %}
|
{% with locator_xyz=node.get_locator_xyz %}
|
||||||
{% if locator_beacon %}
|
{% if locator_xyz %}
|
||||||
<p>
|
<p>
|
||||||
<strong>In Map:</strong>
|
<strong>In Map:</strong>
|
||||||
X={{ locator_beacon.x | cm_to_m }}
|
X={{ locator_xyz.0 | cm_to_m }}
|
||||||
Y={{ locator_beacon.y | cm_to_m }}
|
Y={{ locator_xyz.1 | cm_to_m }}
|
||||||
Z={{ locator_beacon.z | cm_to_m }}
|
Z={{ locator_xyz.2 | cm_to_m }}
|
||||||
</p>
|
</p>
|
||||||
{% else %}
|
{% else %}
|
||||||
<p>
|
<p>
|
||||||
|
|
|
@ -50,6 +50,13 @@ class RangeLocator:
|
||||||
def load_nocache(cls, update):
|
def load_nocache(cls, update):
|
||||||
return pickle.load(open(cls.build_filename(update), 'rb'))
|
return pickle.load(open(cls.build_filename(update), 'rb'))
|
||||||
|
|
||||||
|
def get_xyz(self, address) -> tuple[int, int, int] | None:
|
||||||
|
try:
|
||||||
|
i = self.beacon_lookup[address]
|
||||||
|
except KeyError:
|
||||||
|
return None
|
||||||
|
return tuple(self.beacon_positions[i])
|
||||||
|
|
||||||
cached = None
|
cached = None
|
||||||
cache_update = None
|
cache_update = None
|
||||||
cache_lock = threading.Lock()
|
cache_lock = threading.Lock()
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue