def load_graph_xml(xml, filename, load_all=False): '''load a graph from one xml string''' ret = [] try: root = objectify.fromstring(xml) except Exception as ex: print(filename, ex) return [] if root.tag != 'graphs': return [] if not hasattr(root, 'graph'): return [] names = set() for g in root.graph: name = g.attrib['name'] expressions = [e.text for e in g.expression] if load_all: if not name in names: ret.append(GraphDefinition(name, expressions[0], g.description.text, expressions, filename)) names.add(name) continue if have_graph(name): continue for e in expressions: e = xml_unescape(e) if expression_ok(e): ret.append(GraphDefinition(name, e, g.description.text, expressions, filename)) break return ret
def cmd_graph(args): '''graph command''' usage = "usage: graph <FIELD...>" if len(args) < 1: print(usage) return if args[0][0] == ':': i = int(args[0][1:]) g = mestate.graphs[i] expression = g.expression args = expression.split() mestate.console.write("Added graph: %s\n" % g.name) if g.description: mestate.console.write("%s\n" % g.description, fg='blue') mestate.rl.add_history("graph %s" % ' '.join(expression.split())) mestate.last_graph = g else: expression = ' '.join(args) mestate.last_graph = GraphDefinition(mestate.settings.title, expression, '', [expression], None) grui.append(Graph_UI(mestate)) grui[-1].display_graph(mestate.last_graph, flightmode_colours()) global last_xlim if last_xlim is not None and mestate.settings.sync_xzoom: #print("initial: ", last_xlim) grui[-1].set_xlim(last_xlim)
def __init__(self): self.input_queue = Queue.Queue() self.rl = None self.console = wxconsole.MessageConsole(title='MAVExplorer') self.exit = False self.status = MEStatus() self.settings = MPSettings( [ MPSetting('marker', str, '+', 'data marker', tab='Graph'), MPSetting('condition', str, None, 'condition'), MPSetting('xaxis', str, None, 'xaxis'), MPSetting('linestyle', str, None, 'linestyle'), MPSetting('show_flightmode', bool, True, 'show flightmode'), MPSetting('legend', str, 'upper left', 'legend position'), MPSetting('legend2', str, 'upper right', 'legend2 position') ] ) self.mlog = None self.command_map = command_map self.completions = { "set" : ["(SETTING)"], "condition" : ["(VARIABLE)"], "graph" : ['(VARIABLE) (VARIABLE) (VARIABLE) (VARIABLE) (VARIABLE) (VARIABLE)'], "map" : ['(VARIABLE) (VARIABLE) (VARIABLE) (VARIABLE) (VARIABLE)'] } self.aliases = {} self.graphs = [] self.flightmode_selections = [] self.last_graph = GraphDefinition('Untitled', '', '', [], None)
def __init__(self): self.input_queue = multiproc.Queue() self.rl = None self.console = wxconsole.MessageConsole(title='MAVExplorer') self.exit = False self.status = MEStatus() self.settings = MPSettings([ MPSetting('marker', str, '+', 'data marker', tab='Graph'), MPSetting('condition', str, None, 'condition'), MPSetting('xaxis', str, None, 'xaxis'), MPSetting('linestyle', str, None, 'linestyle'), MPSetting('show_flightmode', bool, True, 'show flightmode'), MPSetting('sync_xzoom', bool, True, 'sync X-axis zoom'), MPSetting('sync_xmap', bool, True, 'sync X-axis zoom for map'), MPSetting('legend', str, 'upper left', 'legend position'), MPSetting('legend2', str, 'upper right', 'legend2 position'), MPSetting('title', str, None, 'Graph title'), MPSetting('debug', int, 0, 'debug level'), MPSetting('paramdocs', bool, True, 'show param docs'), ]) self.mlog = None self.mav_param = None self.filename = None self.command_map = command_map self.completions = { "set": ["(SETTING)"], "condition": ["(VARIABLE)"], "graph": [ '(VARIABLE) (VARIABLE) (VARIABLE) (VARIABLE) (VARIABLE) (VARIABLE) (VARIABLE) (VARIABLE) (VARIABLE) (VARIABLE) (VARIABLE) (VARIABLE)' ], "map": ['(VARIABLE) (VARIABLE) (VARIABLE) (VARIABLE) (VARIABLE)'], "param": ['download', 'check', 'help (PARAMETER)'], } self.aliases = {} self.graphs = [] self.flightmode_selections = [] self.last_graph = GraphDefinition(self.settings.title, '', '', [], None) #pipe to the wxconsole for any child threads (such as the save dialog box) self.parent_pipe_recv_console, self.child_pipe_send_console = multiproc.Pipe( duplex=False) #pipe for creating graphs (such as from the save dialog box) self.parent_pipe_recv_graph, self.child_pipe_send_graph = multiproc.Pipe( duplex=False) self.param_help = param_help.ParamHelp() tConsoleWrite = threading.Thread(target=self.pipeRecvConsole) tConsoleWrite.daemon = True tConsoleWrite.start() tGraphWrite = threading.Thread(target=self.pipeRecvGraph) tGraphWrite.daemon = True tGraphWrite.start()
def __init__(self): self.input_queue = queue.Queue() self.rl = None self.console = wxconsole.MessageConsole(title='MAVExplorer') self.exit = False self.status = MEStatus() self.settings = MPSettings([ MPSetting('marker', str, '+', 'data marker', tab='Graph'), MPSetting('condition', str, None, 'condition'), MPSetting('xaxis', str, None, 'xaxis'), MPSetting('linestyle', str, None, 'linestyle'), MPSetting('show_flightmode', bool, True, 'show flightmode'), MPSetting('legend', str, 'upper left', 'legend position'), MPSetting('legend2', str, 'upper right', 'legend2 position') ]) self.mlog = None self.command_map = command_map self.completions = { "set": ["(SETTING)"], "condition": ["(VARIABLE)"], "graph": [ '(VARIABLE) (VARIABLE) (VARIABLE) (VARIABLE) (VARIABLE) (VARIABLE)' ], "map": ['(VARIABLE) (VARIABLE) (VARIABLE) (VARIABLE) (VARIABLE)'] } self.aliases = {} self.graphs = [] self.flightmode_selections = [] self.last_graph = GraphDefinition('Untitled', '', '', [], None) #pipe to the wxconsole for any child threads (such as the save dialog box) self.parent_pipe_recv_console, self.child_pipe_send_console = Pipe( duplex=False) #pipe for creating graphs (such as from the save dialog box) self.parent_pipe_recv_graph, self.child_pipe_send_graph = Pipe( duplex=False) tConsoleWrite = threading.Thread(target=self.pipeRecvConsole) tConsoleWrite.daemon = True tConsoleWrite.start() tGraphWrite = threading.Thread(target=self.pipeRecvGraph) tGraphWrite.daemon = True tGraphWrite.start()
def cmd_graph(args): '''graph command''' usage = "usage: graph <FIELD...>" if len(args) < 1: print(usage) return if args[0][0] == ':': i = int(args[0][1:]) g = mestate.graphs[i] expression = g.expression args = expression.split() mestate.console.write("Added graph: %s\n" % g.name) if g.description: mestate.console.write("%s\n" % g.description, fg='blue') mestate.rl.add_history("graph %s" % ' '.join(expression.split())) mestate.last_graph = g else: expression = ' '.join(args) mestate.last_graph = GraphDefinition('Untitled', expression, '', [expression], None) display_graph(mestate.last_graph)