@@ -125,6 +125,7 @@ def __init__(self):
125125 "set" : ["(SETTING)" ],
126126 "condition" : ["(VARIABLE)" ],
127127 "graph" : ['(VARIABLE) (VARIABLE) (VARIABLE) (VARIABLE) (VARIABLE) (VARIABLE) (VARIABLE) (VARIABLE) (VARIABLE) (VARIABLE) (VARIABLE) (VARIABLE)' ],
128+ "graphs" : ['(PREDEFINED_GRAPH)' ],
128129 "dump" : ['(MESSAGETYPE)' , '--verbose (MESSAGETYPE)' ],
129130 "map" : ['(VARIABLE) (VARIABLE) (VARIABLE) (VARIABLE) (VARIABLE)' ],
130131 "param" : ['download' , 'check' , 'help (PARAMETER)' , 'save' , 'savechanged' , 'diff' , 'show' , 'check' ],
@@ -371,6 +372,11 @@ def load_graphs():
371372 mestate .graphs .extend (graphs )
372373 mestate .console .writeln ("Loaded %s" % f )
373374 mestate .graphs = sorted (mestate .graphs , key = lambda g : g .name )
375+ # Update completions with actual graph names
376+ if len (mestate .graphs ) > 0 :
377+ # Some default graph names have spaces: replace with -
378+ graph_names = [g .name .replace (' ' , '-' ) for g in mestate .graphs ]
379+ mestate .completions ["graphs" ] = graph_names
374380
375381def flightmode_colours ():
376382 '''return mapping of flight mode to colours'''
@@ -439,6 +445,40 @@ def cmd_graph(args):
439445 #print("initial: ", xlimits.last_xlim)
440446 grui [- 1 ].set_xlim (xlimits .last_xlim )
441447
448+ def cmd_graphs (args ):
449+ '''graphs command'''
450+ usage = "usage: graphs <PREDEFINED_GRAPH_NAME>"
451+ if len (args ) < 1 :
452+ print (usage )
453+ return
454+ check_vehicle_type ()
455+ graph_name = ' ' .join (args )
456+
457+ # Normalize search term and graph names by replacing spaces with dashes
458+ normalized_search = graph_name .replace (' ' , '-' ).upper ()
459+
460+ # Find matching predefined graph
461+ matching_graphs = [g for g in mestate .graphs if normalized_search in g .name .replace (' ' , '-' ).upper ()]
462+ if not matching_graphs :
463+ print ("No predefined graph found matching: %s" % graph_name )
464+ return
465+
466+ # Display the first matching graph
467+ g = matching_graphs [0 ]
468+ mestate .console .write ("Added predefined graph: %s\n " % g .name )
469+ if g .description :
470+ mestate .console .write ("%s\n " % g .description , fg = 'blue' )
471+ mestate .rl .add_history ("graphs %s" % g .name )
472+ mestate .last_graph = g
473+ if mestate .settings .debug > 0 :
474+ print ("Adding graph: %s" % mestate .last_graph .expression )
475+ grui .append (Graph_UI (mestate ))
476+ grui [- 1 ].display_graph (mestate .last_graph , flightmode_colours ())
477+ global xlimits
478+ if xlimits .last_xlim is not None and mestate .settings .sync_xzoom :
479+ #print("initial: ", xlimits.last_xlim)
480+ grui [- 1 ].set_xlim (xlimits .last_xlim )
481+
442482map_timelim_pipes = []
443483
444484def cmd_map (args ):
@@ -1561,6 +1601,7 @@ def main_loop():
15611601
15621602command_map = {
15631603 'graph' : (cmd_graph , 'display a graph' ),
1604+ 'graphs' : (cmd_graphs , 'display a predefined graph' ),
15641605 'set' : (cmd_set , 'control settings' ),
15651606 'reload' : (cmd_reload , 'reload graphs' ),
15661607 'save' : (cmd_save , 'save a graph' ),
0 commit comments