mirror of
https://github.com/paparazzi/paparazzi.git
synced 2026-06-06 07:53:43 +08:00
[python] update control_panel, fix messagepicker
the python plotter, and other tools need some love... Remved the Real-Time Plotter (Python) from control panel as it didn't work. Fixed the messagepicker, but it only prints the ac_id/message/field
This commit is contained in:
@@ -3,14 +3,33 @@
|
||||
from __future__ import absolute_import, print_function
|
||||
|
||||
import wx
|
||||
import getopt
|
||||
import sys
|
||||
import os
|
||||
import time
|
||||
from os import path, getenv
|
||||
|
||||
sys.path.append(os.getenv("PAPARAZZI_HOME") + "/sw/lib/python")
|
||||
# if PAPARAZZI_SRC not set, then assume the tree containing this
|
||||
# file is a reasonable substitute
|
||||
PPRZ_SRC = getenv("PAPARAZZI_SRC", path.normpath(path.join(path.dirname(path.abspath(__file__)), '../../../../')))
|
||||
sys.path.append(PPRZ_SRC + "/sw/lib/python")
|
||||
|
||||
from ivy_msg_interface import IvyMessagesInterface
|
||||
from pprz_msg.message import PprzMessage
|
||||
|
||||
|
||||
import messages_tool
|
||||
class Message(PprzMessage):
|
||||
def __init__(self, class_name, name):
|
||||
super(Message, self).__init__(class_name, name)
|
||||
self.field_controls = []
|
||||
self.index = None
|
||||
self.last_seen = time.clock()
|
||||
|
||||
|
||||
class Aircraft(object):
|
||||
def __init__(self, ac_id):
|
||||
self.ac_id = ac_id
|
||||
self.messages = {}
|
||||
self.messages_book = None
|
||||
|
||||
|
||||
class MessagePicker(wx.Frame):
|
||||
def __init__(self, parent, callback, initIvy = True):
|
||||
@@ -24,27 +43,30 @@ class MessagePicker(wx.Frame):
|
||||
self.tree.Bind(wx.EVT_LEFT_DCLICK, self.OnDoubleClick)
|
||||
self.tree.Bind(wx.EVT_CHAR, self.OnKeyChar)
|
||||
self.Bind( wx.EVT_CLOSE, self.OnClose)
|
||||
self.message_interface = messages_tool.IvyMessagesInterface(self.msg_recv, initIvy)
|
||||
self.message_interface = IvyMessagesInterface(self.msg_recv, initIvy)
|
||||
|
||||
def OnClose(self, event):
|
||||
self.message_interface.Stop()
|
||||
self.message_interface.shutdown()
|
||||
self.Destroy()
|
||||
|
||||
def msg_recv(self, ac_id, name, values):
|
||||
def msg_recv(self, ac_id, msg):
|
||||
if msg.msg_class != "telemetry":
|
||||
return
|
||||
|
||||
self.tree.Expand(self.root)
|
||||
if ac_id not in self.aircrafts:
|
||||
ac_node = self.tree.AppendItem(self.root, str(ac_id))
|
||||
self.aircrafts[ac_id] = messages_tool.Aircraft(ac_id)
|
||||
self.aircrafts[ac_id] = Aircraft(ac_id)
|
||||
self.aircrafts[ac_id].messages_book = ac_node
|
||||
|
||||
aircraft = self.aircrafts[ac_id]
|
||||
ac_node = aircraft.messages_book
|
||||
|
||||
if name not in aircraft.messages:
|
||||
msg_node = self.tree.AppendItem(ac_node, str(name))
|
||||
if msg.name not in aircraft.messages:
|
||||
msg_node = self.tree.AppendItem(ac_node, str(msg.name))
|
||||
self.tree.SortChildren(ac_node)
|
||||
aircraft.messages[name] = messages_tool.Message("telemetry", name)
|
||||
for field in aircraft.messages[name].field_names:
|
||||
aircraft.messages[msg.name] = Message("telemetry", msg.name)
|
||||
for field in aircraft.messages[msg.name].fieldnames:
|
||||
item = self.tree.AppendItem(msg_node, field)
|
||||
|
||||
def OnKeyChar(self, event):
|
||||
|
||||
Reference in New Issue
Block a user